Win a copy of Emmy in the Key of Code this week in the General Computing 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

XML DOM from string

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a method of creating an XML DOM Document by passing in a string rather than a file name / data stream? I'm used to the MSXML parser 'loadXML(myString)' method in VB and wondered if any Java parsers support this (which ones and how would help too).
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With JAXP, I've sucessfully used:

or if you don't like to use deprecated methods, the slightly wordier:

 
Ben Hodgson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that Frank, works like a dream - saved me a great deal of screen-staring. I will probably use the XmlDocument class (rather than DocumentBuilder) to hold my DOM document as it seems to have more in the way of methods for manipulating the XML and extracting / adding nodes.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I had the same problem,i resolved converting XML string to DOM,
but how do i achieve converting DOM back to XML STRING,
i am also uising JAXP, and i did not see XMLDocument anywhere???in the API(i heard it is only in DOM3, and the jaxp
found in sun's web site supports only DOM2.....PLEASE HELP!!!
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!