XML Document. Node vs Elements, and more

From: Jbjones (jbjonesjr_at_gmail.com)
Date: 10/31/04


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
        }
    }



Relevant Pages

  • Re: XML Document. Node vs Elements, and more
    ... Jbjones wrote: ... > 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 ...
    (comp.lang.java.programmer)
  • Multi-input file XSLT problem
    ... I pass in docs.xml and parse it like this, outputting an xml file: ...
    (comp.text.xml)
  • processing dynamic replyto addresses
    ... can parse a root address and ignore, but pass on, wildcard data. ... and to which newsletter the subscriber is replying. ...
    (microsoft.public.exchange.admin)
  • how would I parse this for a configuration file.
    ... I will be including something like the following in a custom section of a ... configuration file. ... How would I parse something like this starting at the root? ...
    (microsoft.public.sqlserver.xml)