Hi, Emma,

     You may paste the follow code into DOMPrint.cpp

/***testing code start ***/

        DOM_Document docu = parser->getDocument();
        DOM_NodeList nodeList = docu.getElementsByTagName("Event");
        DOM_Node     tempNode = nodeList.item(0);

        DOM_Element  newElem = docu.createElement("TypeC");
        DOM_Text     DataVal = docu.createTextNode("TypeC text data, if
any");
        newElem.appendChild(DataVal);
        tempNode.appendChild(newElem);

/*** testing code end ***/

--> original code

        try
        {
            gFormatter = new XMLFormatter(gEncodingName, formatTarget,
                                          XMLFormatter::NoEscapes,
gUnRepFlags);
            cout << doc << endl;
        }

...

     An element <TypeC>TypeC text data. if any</TypeC>
will be added after <TypeB> within <Event> in the output.

Regards,

Peiyong Zhang
____________________________________________
XML Parsers Development
IBM Toronto Laboratory email: [EMAIL PROTECTED]
Phone: (416)448-4088; Fax: (416)448-4414; T/L: 778-4088



"Emma Towey" <[EMAIL PROTECTED]> on 03/22/2001 02:50:11 PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  DOMPrint and manipulating data





 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
/>


Hi all,


I'm having a bit of a problem that hopefully someone will be able to help
me with.


I have an xml file similar to the one below:





<Logger>


            <Event>


                        <TypeA>


                                    <A_ID>0</A_ID>


                                    <message>feeder not found</message>


                        </TypeA>


                        <TypeB>


                                    <B_ID>22</B_ID>


                                    <Time>11</Time>


                                    <Date>12Feb</Date>


                        </ TypeB >


            </Event>


</Logger>





What I want to be able to do is read in this file append a Node TypeC after
TypeB but still inside the Event Node, and then Print out the file to the
screen but also save it so that it overwrites the original file.


I have been using the DOMPrint Class to do this and I am able to read in
and print out the file but I still can't figure out how to manipulate the
data before printing it. I have tried methods similar to those used in
CreateDOMDocument but hence far have had no success.


I would greatly appreciate all suggestions.


Thanks,


Emma






Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


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