Re: DocumentBuilder from byte/packet
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 = ""; StringReader reader = new StringReader(xml); InputSource source = new InputSource(reader); Document doc = db.parse(source); System.out.println(doc.getChildNodes().item(0)); } { byte[] xml = "".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
Re: DocumentBuilder from byte/packet
Any drawbacks on using input streams? DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); { String xml = ""; StringReader reader = new StringReader(xml); InputSource source = new InputSource(reader); Document doc = db.parse(source); System.out.println(doc.getChildNodes().item(0)); } { byte[] xml = "".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
DocumentBuilder from byte/packet
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