GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Help with parsing an xml string java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Help with parsing an xml string java" Watch "Help with parsing an xml string java" New topic
Author

Help with parsing an xml string java

Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
I can parse a file or an InputStream without no problems, but I call a function which returns an xml string and I need to parse this
String strMe = "localhost";
Document doc;
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder db=dbf.newDocumentBuilder();
String parseme = hostLookup.LookupAddress(strMe);
doc=db.parse(parseme);
I get a SAXException not found the string is returning ok but I need to parse the string not a file I dont want to put it in a file if I did it would work but is there a way to build an InputStream with this strMe string
Thanks in Advance
Ray


SCJO, SCJD, SCWCD, I-Net+, A+, Network+, MCSD, MCDBA, MCP, MCT
Zakaria Haque
Ranch Hand

Joined: Jan 02, 2002
Posts: 60
use something like,
doc=db.parse(new org.xml.sax.InputSource(new StringReader(parseme)));


tobe bondhu nouka bherao<br />shonabo gaan aj shara raat
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Moving from Servlets -> XML, XSL, DOM and SAX
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with parsing an xml string java