Shiet... found an error as soon as I sent the code.

DOM_document oDoc = parser.parse(something);
{
  DOM_Element oRoot = oDoc.getRootElement();
  DOM_Element oNode_Node1 = oRoot.getFirstChild();
  while (oNode_Node1 != NULL) {
    DOM_Element oNode_Node2 = oNode_Node1.getFirstChild();
    DOM_Element oNode_Node3 = oNode_Node2.getNextSibling();

>>    DOM_Text oTextNode_Node2 = oNode_Node2.getFirstChild();
>>    DOM_Text oTextNode_Node3 = oNode_Node3.getFirstChild();

    DOMString oText_Node2 = oTextNode_Node2.getNodeValue();
    DOMString oText_Node3 = oTextNode_Node3.getNodeValue();

    // Do something with the texts

    oNode_Node1 = oNode_Node1.getNextSibling();
  }
}
oDoc = 0; // Release the document memory

/ Erik

-----Original Message-----
From: Erik Rydgren [mailto:[EMAIL PROTECTED]]
Sent: den 3 december 2001 10:41
To: [EMAIL PROTECTED]
Subject: RE: Hi ...Help required for DOM Parser
Sensitivity: Confidential


Should be something like this:

DOM_document oDoc = parser.parse(something);
{
  DOM_Element oRoot = oDoc.getRootElement();
  DOM_Element oNode_Node1 = oRoot.getFirstChild();
  while (oNode_Node1 != NULL) {
    DOM_Element oNode_Node2 = oNode_Node1.getFirstChild();
    DOM_Element oNode_Node3 = oNode_Node2.getNextSibling();

    DOM_Element oTextNode_Node2 = oNode_Node2.getFirstChild();
    DOM_Element oTextNode_Node3 = oNode_Node3.getFirstChild();

    DOMString oText_Node2 = oTextNode_Node2.getNodeValue();
    DOMString oText_Node3 = oTextNode_Node3.getNodeValue();

    // Do something with the texts

    oNode_Node1 = oNode_Node1.getNextSibling();
  }
}
oDoc = 0; // Release the document memory

Also read the Xerces DOM API here:
http://xml.apache.org/xerces-c/apiDocs/index.html

Note that this code is written on top of my head and I might even got the
class names and methods wrong but it should give you an idea where to begin,
also note that the code lacks everything that resembles fault managment.

/ Erik


-----Original Message-----
From: Ravi_Jain [mailto:[EMAIL PROTECTED]]
Sent: den 3 december 2001 10:19
To: [EMAIL PROTECTED]
Subject: RE: Hi ...Help required for DOM Parser
Sensitivity: Confidential


thanks for the info .
I am using DOM as my xml is not that large .
Kindly let me know which methods to use to iterate the loop for the case
where I have more that one <node1></node1> so that I can read all elements
iteratively
Ravi Jain


> ----------
> From:         Erik Rydgren[SMTP:[EMAIL PROTECTED]]
> Reply To:     [EMAIL PROTECTED]
> Sent:         Monday, December 03, 2001 14:48
> To:   [EMAIL PROTECTED]
> Subject:      RE: Hi ...Help required for DOM Parser
> Sensitivity:  Confidential
>
> Well reading nodes is what a XML parser does best... :) j/k
>
> You were not very specific about what you want to accomplish but if you
> parse the file as you described then the resulting DOM tree looks like
> this:
>
> <node1>
>   <node2>
>     <#text> nodevalue=datax
>   <node3>
>     <#text> nodevalue=datay
> <node1>
>   <node2>
> ... and so on
>
> Which makes it easy to know which data that belongs to which node. DOM
> will
> read the WHOLE file into memory at once. If that is not desirable then you
> want to take a look at SAX instead. Take a look here if you are unsure if
> you want to use DOM or SAX.
>
> http://www.sdc.iup.edu/outreach/fall2000/xml2/domvssax.html
>
> Regards
>
> Erik Rydgren
> Mandarinen systems AB
> Sweden
>
> -----Original Message-----
> From: Ravi_Jain [mailto:[EMAIL PROTECTED]]
> Sent: den 3 december 2001 07:24
> To: [EMAIL PROTECTED]
> Subject: Hi ...Help required for DOM Parser
> Sensitivity: Confidential
>
>
> Hi All
>
> I am a new user of XML(DOM).
> I have a specific requirement where in I want to have a functionality:
> for example:
> <node1>
>       <node2>datax</node2>
>       <node3>datay</node3>
> </node1>
>
> I have am xml file where in I will have a number of <node1> tags
> I want to read each node1 along with node2 and node3 corresponding to each
> node1 .
> Plz let me know so as to how can I do with the above requirement.
> Thanks in Advance
>
>
> Ravi Jain
>
> **************************************************************************
> This email (including any attachments) is intended for the sole use of the
> intended recipient/s and may contain material that is CONFIDENTIAL AND
> PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
> or
> distribution or forwarding of any or all of the contents in this message
> is
> STRICTLY PROHIBITED. If you are not the intended recipient, please contact
> the sender by email and delete all copies; your cooperation in this regard
> is appreciated.
> **************************************************************************
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to