Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » XML Parser
XML Parser [message #37362] Mon, 19 May 2003 04:31 Go to next message
Eclipse UserFriend
Originally posted by: lovoni6.hotmail.com

Hi Everybody!

I tried to parse an xml file using the following code
public void processFile() {

try {

DocumentBuilder
docBuilder=DocumentBuilderFactory.newInstance().newDocumentB uilder();

Document
doc=docBuilder.parse("c:\\resources\\files\\Miscellaneous.xml ");
//org.w3c.dom.Document

NodeList list=doc.getChildNodes();
//org.w3c.dom.NodeList

for (int ii = 0; ii < list.getLength(); ii++) {

System.out.println(list.item(ii).getNodeName());
// returns the node name

System.out.println(list.item(ii).getNodeValue());
//returns null

NodeList list1=list.item(ii).getChildNodes();

for (int jj = 0; jj < list1.getLength(); jj++) {


System.out.println("\t"+list1.item(jj).getNodeName());


System.out.println("\t"+list1.item(jj).getNodeValue());
//returns null

NodeList list2=list1.item(jj).getChildNodes();

//.....

}

}

}

catch(Exception e){}

}

but all calls to Node.getNodeValue() return null.

How can I solve the problem? Is there another mean(classes), within the
eclipse platform, to parse xml file and get node values?



Thanks for help.
Re: XML Parser [message #37529 is a reply to message #37362] Mon, 19 May 2003 06:36 Go to previous message
Eclipse UserFriend
Originally posted by: lovoni6.hotmail.com

It works with the following code

public void processFile() {

try {

DocumentBuilderImpl
docBuilder=DocumentBuilderFactoryImpl.newInstance().newDocum entBuilder();

DocumentImpl
doc=docBuilder.parse("c:\\resources\\files\\Miscellaneous.xml ");
//org.apache.xerces.dom.DocumentImpl

NodeList list=doc.getChildNodes();

for (int ii = 0; ii < list.getLength(); ii++) {
NodeImpl node=(NodeImpl )list.item(ii);

System.out.println(node.getNodeName());

System.out.println(node.getTextContent());
}

}

"Castor" <lovoni6@hotmail.com> wrote in message
news:baa4gb$lu4$1@rogue.oti.com...
> Hi Everybody!
>
> I tried to parse an xml file using the following code
> public void processFile() {
>
> try {
>
> DocumentBuilder
> docBuilder=DocumentBuilderFactory.newInstance().newDocumentB uilder();
>
> Document
> doc=docBuilder.parse("c:\\resources\\files\\Miscellaneous.xml ");
> //org.w3c.dom.Document
>
> NodeList list=doc.getChildNodes();
> //org.w3c.dom.NodeList
>
> for (int ii = 0; ii < list.getLength(); ii++) {
>
> System.out.println(list.item(ii).getNodeName());
> // returns the node name
>
> System.out.println(list.item(ii).getNodeValue());
> //returns null
>
> NodeList list1=list.item(ii).getChildNodes();
>
> for (int jj = 0; jj < list1.getLength(); jj++) {
>
>
> System.out.println("\t"+list1.item(jj).getNodeName());
>
>
> System.out.println("\t"+list1.item(jj).getNodeValue());
> //returns null
>
> NodeList list2=list1.item(jj).getChildNodes();
>
> //.....
>
> }
>
> }
>
> }
>
> catch(Exception e){}
>
> }
>
> but all calls to Node.getNodeValue() return null.
>
> How can I solve the problem? Is there another mean(classes), within the
> eclipse platform, to parse xml file and get node values?
>
>
>
> Thanks for help.
>
>
Previous Topic:Unicode support in standard Eclipse views?
Next Topic:A date for Eclipse 2.1.1
Goto Forum:
  


Current Time: Fri May 23 11:16:32 EDT 2025

Powered by FUDForum. Page generated in 0.03776 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top