I'm writing some code that's loosely based on the SerializeNodeSet
example. I evaluate an XPath expression using selectNodeList() which
returns a NodeRefList of 3 nodes. Each of them is an element and each
of them has 2 child elements, i.e.
<A>
<B>BVaue</B>
<C>CVaue</C>
<D>DVaue</D>
</A>
(repeat twice)
I'm able to walk that list and display the node names and values. I
need to descend into the child nodes and get their values. So in a for
loop over the list of <A>'s, I get a XalanNode* with the item(i) method
and then do a getChildNodes() on that. However, I get compile errors
when I try to use the XalanNodeList* that I get back from
getChildNodes(). I get "use of undefined type" errors trying to use the
node list pointer, specifically:
C:\Proj\src\libs\Profile\Profile.cpp(1588) : error C2027: use of
undefined type 'XalanNodeList'
c:\proj\3rdparty\include\xalanc\xalandom\xalannode.hpp(32) : see
declaration of 'XalanNodeList'
I've tried casting the node pointer to an Element pointer based on some
code I found in the list archive, trying to give the node list a type
but that was no help. Any help from someone here would be greatly
appreciated. Relevant code snippets follow:
NodeRefList theResult;
theEvaluator.selectNodeList(theResult,
_domSupport,
pContextNode,
XalanDOMString(xpathExpr).c_str(),
_pXmlDoc->getDocumentElement());
const NodeRefList::size_type theLength = theResult.getLength();
for (NodeRefList::size_type i = 0; i < theLength; ++i)
{
XalanNode* theNode = theResult.item(i);
assert(theNode != 0);
const XalanNode::NodeType theNodeType = theNode->getNodeType();
displayNodeType(theNodeType);
if (theNodeType == XalanNode::ELEMENT_NODE)
{
/* element node */
if (theNode->hasChildNodes())
{
const XalanNodeList* pChildren = pParent->getChildNodes();
//===> /* ** this line gets a compile error ** */
unsigned int numChildren = pChildren->getLength();
for (unsigned int i = 0; i < numChildren; i++)
{
//===> /* ** this line gets a compile error ** */
XalanNode* pChild = pChildren->item(i);
XalanDomCString nodeName(pChild->getNodeName());
XalanDomCString nodeValue(pChild->getNodeValue());
/* display name and value */
}
}
} /* end (element node) */
}