Hi, Dave,
I've got a question for you, what shall i do in the 2nd return below?
thanks.
// Finds and returns the first child element node.
DOM_Element XUtil::getFirstChildElement(DOM_Node parent)
{
// search for node
DOM_Node child = parent.getFirstChild();
while (child != 0)
{
if (child.getNodeType() == DOM_Node::ELEMENT_NODE)
return static_cast<DOM_Element&>(child); /*** 1st return
***/
child = child.getNextSibling();
}
// not found
return ??? // 2nd return
}
Regards,
Peiyong Zhang
____________________________________________
XML Parsers Development
IBM Toronto Laboratory email: [EMAIL PROTECTED]
Phone: (416)448-4088; Fax: (416)448-4414; T/L: 778-4088
David N Bertoni/CAM/Lotus@Lotus on 03/23/2001 10:43:34 AM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc:
Subject: RE: Casting DOM_Node to DOM_Element
As per Andy Heninger's note yesterday, you cannot use dynamic_cast on
DOM_Node and its descendants, since they have no virtual functions. You
must use getNodeType(), which certainly will return the proper type.
Dave
"David E.
Cleary" To:
<[EMAIL PROTECTED]>
<davec@progre cc: (bcc: David N
Bertoni/CAM/Lotus)
ss.com> Subject: RE: Casting DOM_Node
to DOM_Element
03/23/2001
06:20 AM
Please
respond to
xerces-c-dev
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of John
> Snelson
>
> The C++ way of doing this is the following code fragment:
>
> if(node.getNodeType() == DOM_Node::ELEMENT_NODE) {
> DOM_Element element = static_cast<DOM_Element&>(node);
> }
Wouldn't dynanic_cast be more what Curt is looking to do, as that will
actually perform a runtime check to see in node is indeed a DOM_Element?
I've never used these casting constructs myself, so I am interested in
hearing other's thoughts on them.
David Cleary
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]