You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by John Meyer <jo...@yahoo.com> on 2003/03/12 05:17:57 UTC

Got it to write, now need to read it back in.

I finally have my document:

<?xml version="1.0" encoding="UTF-16" standalone="no"
?><files><file><name>CSAP
data.sxc</name><size>56670</size><category><patches/></category><subcategory
>test</subcategory><uuhash>jkf;dlsjafkdl;jkdf</uuhash><comments>This is a
test.</comments></file></files>

Now, I am trying to read out the files using this basic code:

DOMDocument *myfiles = parser->getDocument();
        DOMElement *root = myfiles->getDocumentElement();
        DOMNodeList *List = root->getElementsByTagName(WideString("file"));

Am I on the right track, and if so, my next question is how do I pull off
the various elements and read them.  For instance, the <uuhash>, etc.


_________________________________________
John Meyer
Programmer
ICQ#: 63450423
More ways to contact me: http://wwp.icq.com/63450423
_________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Got it to write, now need to read it back in.

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,

> I finally have my document:
> 
> <?xml version="1.0" encoding="UTF-16" standalone="no"
> ?><files><file><name>CSAP
> data.sxc</name><size>56670</size><category><patches/></category><subcategory
> >test</subcategory><uuhash>jkf;dlsjafkdl;jkdf</uuhash><comments>This is a
> test.</comments></file></files>
> 
> Now, I am trying to read out the files using this basic code:
> 
> DOMDocument *myfiles = parser->getDocument();
>         DOMElement *root = myfiles->getDocumentElement();
>         DOMNodeList *List = root->getElementsByTagName(WideString("file"));
> 
> Am I on the right track, and if so, my next question is how do I pull off
> the various elements and read them.  For instance, the <uuhash>, etc.

List will contain all the file elements. DOMNodeList provides methods to 
access items in the list. If you want to navigate from the nodes then take 
a look at methods such as getFirstChild and getNextSibling on DOMNode. If 
you are going to do this kind of thing a lot then consider using XPath. 
Then you could go something like this to get to uuahsh

/files/file/uuhash


If you want this functionality take a look at Pathan 
(software.decisionsoft.com) or xalan (an apache project).


Gareth


-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org