aspose file tools
The moose likes XML and Related Technologies and the fly likes Parsing a String using DOM API Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Parsing a String using DOM API" Watch "Parsing a String using DOM API" New topic
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: 5781
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 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: 11862
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]

 
IntelliJ Java IDE
 
subject: Parsing a String using DOM API
 
Threads others viewed
Convert String to XML, then search for text
DOM issue
DOM or SAX confusing
JSP and XML
Parsing XML string using Java Program
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture