• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

convert multiple xml tags to single tag with attributes

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic