Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

from an xml String to the xml root element

Status
Not open for further replies.

Cruisy

Programmer
Oct 11, 2002
8
BE
I'm having a hard time getting the root element from an xml string

I get the xml in a String format and need the rootelement

anyone know how to do this.
It should be something with making it into a Document and then retrieving the root element i think but i seem to be looking over it..

any help is welcome (-:
 
Hi,
I am using the XML xerces parser. Here an example I used to load a string in a DOM structure :

String strXml = args[0] ;
Document myXmlDocument ;
DOMParser myDOMParser = new DOMParser();
myDOMParser.parse(new InputSource(new ByteArrayInputStream(strXml.getBytes())));
myXmlDocument = myDOMParser.getDocument();

So, I use myXmlDocument to get its diffrents nodes, the same way like I do with XML Files.

Hope this helps.

Rim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top