This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes convert multiple xml tags to single tag with attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "convert multiple xml tags to single tag with attributes " Watch "convert multiple xml tags to single tag with attributes " New topic
Author

convert multiple xml tags to single tag with attributes

prabhu peruka
Greenhorn

Joined: Oct 31, 2004
Posts: 5
hi all,
I am trying to create a java program which will take an SOAP/XML input format and generate xml of my own format...

i am new to xml technologies so totally confused what to do...
I am trying to look for some sample code which does the same.

do i need to use any parsers like SAX / DOM ?

What i am actually looking at is :

when the user input comes to me as xml file, i want to capture each tag value and store it as attribute value in my output xml. i.e; in my output what i have is a single tag with many attributes

if sample input file:

<soap-env:Envelope
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
</soap-env:Header>
<soap-env:Body CLASS_TYPE="Request">
<Query>
<name>prabhu</name>
<Address1>#123</Address1>
<Address2></Address2>
<Address3></Address3>
<CityName>hyd</CityName>
<StateCode>ap</StateCode>
<StateName></StateName>
<CountryCode>IND</CountryCode>
<PostalCode>123456</PostalCode>
<CountryName>INDIA</CountryName>
<LastName></LastName>
<FirstName></FirstName>
</Query>
</soap-env:Body>
</soap-env:Envelope>

then, the sample output would be :

<user
name_1="prabhu"
address_1="#123"
address_2=""
address_3=""
city="hyd"
state_name=""
state_code="AP"
postal_code="123456"
ctry_name="India"
ctry_code="IND"

/>


Pls, help me on this ...
Thanks in advance.
 
Consider Paul's rocket mass heater.
 
subject: convert multiple xml tags to single tag with attributes
 
Similar Threads
SOAP Header problem SAAJ
Spring-ws client with Jax-ws web service
How do I catch a user define exception on the client (SOAP/JAX-RPC/WSDL)
KSoap2 question, please reply
H