This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to convert String of XML elements into Document Object

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have written a parser which can parse a xml document using the following way.

xmlDoc = new SAXBuilder().build(eventConfigFile);

where eventConfigFile is my XML file . This parser successfully parses a XML document.

Now here is my problem. In real world this input would not be a XML file. it would be a one continous String with the contents of the XML file.
example:
"<DatahubRequest><Job>DHTest.Tibco</Job><ExternalID>12354</ExternalID><Source><Source_Location>RC_test</Source_Location><Source_Filename>DH_Test_in_20080811</Source_Filename><Source_Daydecrement>0</Source_Daydecrement></Source><Target><Target_Location>RC_test_11</Target_Location><Target_Filename>DH_Test_in_11111</Target_Filename><Target_Daydecrement>1</Target_Daydecrement></ Target><Target><Target_Location>RC_test_22</Target_Location><Target_Filename>DH_Test_in_2222</Target_Filename><Target_Daydecrement>1</Target_Daydecrement></Target></DatahubRequest>"

This string will be actually a pushed as a message on TIBCO EMS and i will pull it from there and read it as XML and extract the values and build my Objects.

How do i generate a Document Object out of this String which contains XML and parse it.
 
Sheriff
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to look at the documentation of that SAXBuilder class and see what kind of inputs it can take. It isn't part of the standard Java API, so we (at least I) can't look at the documentation for you because we (at least I) don't know where it is.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!