Shalmi wrote:
David Bertoni wrote:
Paul Lalonde wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
So now I'm further confused - I tried calling XalanNode::getChildren(),
but recieved an XalanDOMException with value 9 = NOT_SUPPORTED_ERR.
Clearly I'm asking for the wrong thing. What's the right thing?
This is a deliberate limitation in Xalan-C's implementation, to save
memory. Because the processor never needs to see a list of the children,
only the iterative member functions are implemented. Try the following
code:
XalanNode* child = node->getFirstChild();
while(child != 0)
{
...
child = child->getNextSibling();
}
Dave
Hi,
Consider following XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
It has four text nodes/elment(?). So if i run "/bookstore/book[1]"
getNodeValue() on this,what should i get?
Element nodes do not have values in the "DOM" representation of the data
model. The values you are looking for are their text node children. And
don't forget that the whitespace you're using for indentation is also
considered part of the document's content, and will be represented by text
nodes.
There are some helper functions in DOMSupport/DOMServices.hpp that will
retrieve what the XPath recommendation defines as the data in a particular
node. You could use those, although I'm not sure they will return what
you're looking for, since I'm not really sure what you're looking for.
I did traversed through the node and print it,but in this case I get null
string. The same piece of code works for "/bookstore/book/year".
I mean if i have to print following output what would be the generic
approach?
1. For "/bookstore/book[1]" i should get <book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
XalanNode::getNodeValue() returns _values_ of nodes, not their markup. If
you want the generate the markup for a node, take a look at the
SerializeNodeSet sample application.
2. For "/bookstore/book/year" i should get
2005
2003
Those are the values of the text node children of the year element nodes.
Dave