• 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 ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to convert String of XML elements into Document Object  RSS feed

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.
"<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.
Posts: 23646
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!