| Author |
Parsing a String using DOM API
|
Lakshmi Ramachandran
Greenhorn
Joined: Jun 26, 2001
Posts: 26
|
|
Hi Folks, I am writing an application in Java using DOM API. I have done the parsing of an XML document by passing its file name as a String parameter to the parse method of DOMParser class. This woks fine. Now, I would like to pass the XML documentas a String and parse. Please help me doing this task. Regards, Lakshmi
|
 |
Ajith Kallambella
Sheriff
Joined: Mar 17, 2000
Posts: 5782
|
|
In order to parse an XML string, you will need to use an InputSource instance. Try this - Hope that helps! ------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
|
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
|
 |
Lakshmi Ramachandran
Greenhorn
Joined: Jun 26, 2001
Posts: 26
|
|
Thank you Ajith, I am currently using ByteArrayInputStream object as a parameter to InputSource constructor. I will try with StringBufferInputStream now. But otherwise, instead of using InputSource, is there any way of sending XML String for parsing ! Please let me Know. Regards, Lakshmi  [This message has been edited by Lakshmi Ramachandran (edited July 17, 2001).] [This message has been edited by Lakshmi Ramachandran (edited July 17, 2001).]
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
Look at the API for your parser. In JAXP 1.1 I find parse() methods with input of File, InputSource, InputStream, and URI. Bill ------------------ author of:
|
Java Resources at www.wbrogden.com
|
 |
Mahesh Siddanati
Greenhorn
Joined: Jul 17, 2001
Posts: 3
|
|
Hello, i was trying to do what u had suggested for parsing an xml string,but the compiler says C:\Mahesh\BlueEdge>javac -deprecation testxml.java testxml.java:73: warning: java.io.StringBufferInputStream in java.io has been deprecated InputStream is = new StringBufferInputStream(xmldata) ; ^ 1 warning any ideas what i should be using instead Thanks, Mahesh
Originally posted by Ajith Kallambella: [B]In order to parse an XML string, you will need to use an InputSource instance. Try this - Hope that helps! [/B]
|
 |
 |
|
|
subject: Parsing a String using DOM API
|
|
|