Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem parsing xml string using dom parser

 
Balamurugan Sundararajan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to parse a Xml String using a Dom parser......the parse function in dom parser takes only input stream as argument.......so i made the code as
InputStream inputstream = new StringBufferInputStream(XmlData) ;
InputSource inputSource = new InputSource(inputstream );
but saxexception is coming and also warning called
"java.io.StringBufferInputStream in java.io has been deprecated"
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried it but see wheether it can take StreamSource

javax.xml.transform.stream.StreamSource xmlSource=new javax.xml.transform.stream.StreamSource(new StringReader(new String(inputXML)));
 
Swarup Kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
StringBufferInputStream class does not convert properly character into bytes.Instead use StringReader class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic