Hi,
Thanks for the help from everyone. As David said, I can use the code he
demonstrated to get the value in the attribute of a node.
However, when I'm trying the same with xalan-c 1.3 (that is the version I have
to work with), I can't do so since an exception is being thrown.
Its being thrown at this point in the code:
const NodeRefList theResult =
theEvaluator.selectNodeList(theDOMSupport,
theContextNode,
XalanDOMString(xpath.c_str()).c_str(),
theDocument->getDocumentElement());
That seems to work fine when I compile using xalan 1.5, but when I use xalan
1.3 , an exception is being thrown whenever the xpath that is given is tryign
to select an attribute ("//name/@first" being the example in this case).
Can anyone throw any light/advice on what I can do to obtain a collection of
all the "first" names from the foo.xml example that's distributed alongwith
xalan-c++ ?
Thanks,
Kaushal
>===== Original Message From [EMAIL PROTECTED] =====
>> However, I still am facing the issue about getting all the values in an
>> attribute, as below:
>
>An attribute only has one value, so I don't understand what you mean by
>"getting all the values."
>
>> INSTEAD, I get:
>> bash-2.03$ mySerializeNodeSet SerializeNodeSet/foo.xml / /doc/name/@first
>>
>> Warning: An attribute or namespace node was selected. Attribute and
>namespace
>> nodes cannot be serialized.
>
>The sample shows how you can serialize XML. When serializing XML, you
>cannot serialize an attribute, because it appears on the element to which
>it belongs. If you want to get values out of a document using XPath
>expressions, XML serialization is not the answer.
>
>You should write your own code that selects a node-set, the prints out the
>values:
>
>for (NodeRefList::size_type i = 0; i < theLength; ++i)
>{
> const XalanNode* const theNode = theResult.item(i);
> assert(theNode != 0);
>
> cout << DOMServices::getNodeValue(*theNode) << endl;
>}
>
>Dave