XML Document. Node vs Elements, and more
From: Jbjones (jbjonesjr_at_gmail.com)
Date: 10/31/04
- Next message: Ann: "Re: Stupid null pointer exception"
- Previous message: Tony Morris: "Re: Stupid null pointer exception"
- Next in thread: Sudsy: "Re: XML Document. Node vs Elements, and more"
- Reply: Sudsy: "Re: XML Document. Node vs Elements, and more"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Oct 2004 16:28:16 -0700
I am parsing a document, so am using nodelist to get the children of
the root, and using logic to parse the Nodes depending on which one it
is. however, I need more power than "Node" can give me. So can I
somehow convert a Node to an Element (I basically need the ability to
read the attributes of an item as well as just get the value).
However, they don't have an ID that i could accurately read to use the
getElementByID() tag. So how can i convert a node to an element? Or
is there a better way for me to go about this instead of root ->
Nodelist ??
Here is some sample code:
Element docRoot= documentWx.getDocumentElement(); // get root
NodeList elements =docRoot.getChildNodes();
elements=elements.item(1).getChildNodes();
//The NodeList now holds everything under Data
for(int counter=0;counter<elements.getLength();counter++)
{
tempNode = (elements.item(counter));
Current = (Element) tempNode;
if(Current.getNodeName()=="Location")
{
//Read 'Location' , element properties of latitude, longitude
}
}
- Next message: Ann: "Re: Stupid null pointer exception"
- Previous message: Tony Morris: "Re: Stupid null pointer exception"
- Next in thread: Sudsy: "Re: XML Document. Node vs Elements, and more"
- Reply: Sudsy: "Re: XML Document. Node vs Elements, and more"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|