• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Writing a DOM's contents to a String

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know if there is a quick and easy way (using JAXP or any other Java XML parser) to convert the contents of a DOM to a String?
I am used to working with Microsoft's parser so I apologize for the comparison (again), but MSXML's DOMDocument object has a method, .xml() which will convert the contents of the DOM into a String.
Example:
l_sXML = l_oXML.xml
Debug.Print l_sXML
The output might be something like "<junk><stuff>This is junk</stuff></junk>". This can then be passed around in code as a String.
Anything like this in a (Java) DOM?
Thanks.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use the XMLSerializer that comes bundled with Xerces.
Here's a small code example -

Note that since XMLSerializer can write to any OutputStream, you can either write to a file or a String.
Hope that helps!

------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
[This message has been edited by Ajith Kallambella (edited June 07, 2001).]
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic