> David N Bertoni/Cambridge/IBM wrote:
>
> >
> > 1. XMLString::transcode() returns a pointer to dynamic memory that
you
> > must delete. If you don't, it's a memory leak:
> >
> > char* str = XMLString::transcode(...);
> >
> > delete [] str;
> >
> >
> I am assigning this value to a string... do I have to delete this
> string, too ??
I don't know what you mean by "assigning this value to a string," so I
can't really answer your question. I suspect the answer is no, but all I
can really tell you is the pointer which is returned by
XMLString::transcode() is a pointer to memory which was dynamically
allocated, so you must delete it when you're finished with it.
> > 2. Element nodes have no value, so getValue() is probably returning a
> > null pointer. The "value" of an Element is contained in its Text
> > children, so you must iterate through the children to get the value.
> >
> According to the API getNodeValue() returns a const XMLCh*.. what does
> the returnvalue contain, if not the text of the node 'element' ?? Even
> if it returns null, why does it crash ?? this null value should be
> assigned to string....!??
Elements have no text value, so you get a null pointer when you call
getNodeValue()-- that's the way the API is designed to work. Your code
crashes probably because you're passing a null pointer to
XMLString::transcode(), which you shouldn't do.
> Do you have any hints, which classes/methods/mechanisms to use, when
> iterating through the Text Children ??
You can either call getChildNodes() to get a list of the children, or call
getFirstChild() to get the first child, then call getNextSibling() on each
child node, until you reach the end of the children. Take a look at some
of the sample programs for more information and code samples.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]