Hello all!
I just began to use Apache XML for my C++ /MFC
app.
So far I can read in my XML-File and read the
data.
I used the sample code to get access to nodes,
names and values.
I know how to access the attributes and
corresonding values.
But I am a bit confused about getting the Text
inside a Tag:
In the XML I have:
...
<NOTE>This is the text to read for the
note</NOTE>
...
Currently I use the following, which seems to work, but seems
also
to be a bit complicated. Is there an easier/safer way to
get
the text ("This is the text to read for the
note").
// Handler to extract the text of a Node with
Name "NOTE"
//
void
XMLParser::ParseVerbNote (DOM_Node& rNote)
{ /* No, this obviously does not
work!!!
DOMString ds = rNote.getNodeValue(); CString cs = ds.rawBuffer(); */ CString note("");
DOM_NodeList childs =
rNote.getChildNodes();
// Works, but seems complicated! Is the direct
text of a node alway childs.item(0) ???
int cntCld =
childs.getLength();
if( cntCld != 0 ) { for(int j = 0; j < cntCld; j++ ) { DOM_Node child = childs.item(j); DOMString ds = child.getNodeValue(); note = ds.rawBuffer(); } }
dp_bufAgt->SetVerbNote((LPCTSTR)note); // writing to my internal data
format
} Thanks for any hints.
Nathan Troxler
|
- Re: Newby question: Get Text of a Node Nathan Troxler
- Re: Newby question: Get Text of a Node Andy Heninger
- RE: Newby question: Get Text of a Node Anthony Dodd