No I think that will work just fine.
Thank you.
Frank
Mike Haller wrote:
Any drawbacks on using input streams?
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
{
String xml = "<?xml version=\"1.0\"?><foo></foo>";
StringReader reader = new StringReader(xml);
InputSource source = new InputSource(reader);
Document doc = db.parse(source);
System.out.println(doc.getChildNodes().item(0));
}
{
byte[] xml = "<?xml version=\"1.0\"?><bar></bar>".getBytes();
InputStream inputstream = new ByteArrayInputStream(xml);
Document doc = db.parse(inputstream);
System.out.println(doc.getChildNodes().item(0));
}
Frank schrieb:
Was tring to figure out the best way to take an XML document that I
have read in from a datagram socket stored in a DatagramPacket(can
convert to byte or String etc) to be able to parse it using
DocumentBuilder using a DOM parse. All the methods seem to work off
of a file or a steam. any thoughts?
Thanks,
Frank