At 20.40 11/08/2005 -0700, Dhirendra Pal Singh wrote:
Hi All,

I have the following xml...

<my-values name "value 1">
        <value>http://127.0.0.1:9955</value>
</my-values>

Now I can read all the attributes of my-values using getAttributes().
Then I can get a DOMElement to value too. But I am unable to get the
value of value which should be "http://127.0.0.1:9955"; I have trying
to do it for last 4 hrs, and is unable to do it. Anyhelp would be
greately appreiciated.

I also tryied the following..=

XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* elm1 = (element pointing to va=
lue)

XERCES_CPP_NAMESPACE_QUALIFIER DOMAttr *valueAttr =
elm1->getAttributeNode(XERCES_CPP_NAMESPACE_QUALIFIER
XMLString::transcode("value"));

But valueAttr is always null... Any reason why?

Because there is no "value" attribute on the "value" element... You need to retrieve the first child of the element (it's a TEXT_NODE) and get its value.

DOMNode* child=elm1->getFirstChild();
if(child)
 XMLCh* value=child->getNodeValue();

As an alternative, use

elm1->getTextContent()

but this API has implications (memory usage grows, and when used on complex elements it returns a string that maybe it's different from what you would expect)

Alberto


Thanks a ton in advance...
--
Thanks
/dev/dp


Reply via email to