• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with parsing an xml string java

 
Ray Smilgius
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Zakaria Haque
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use something like,
doc=db.parse(new org.xml.sax.InputSource(new StringReader(parseme)));
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving from Servlets -> XML, XSL, DOM and SAX
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic