No on both counts.  A DOMElement need not have children, and if it does,
the first one could be another element or a comment (for example).

It seems that you're finding your way around XML as well as Xerces.  You
may find that a little time spent with an introductory text (on XML
syntax and the DOM) is well repaid.  Or, if you're a compulsively
detail-oriented masochist, you could always read the specs at
http://www.w3.org/TR/.

-----Original Message-----
From: Patrick M. Rutkowski [mailto:[email protected]] 
Sent: Tuesday, May 18, 2010 2:36 PM
To: [email protected]
Subject: DOMElement, mandatory DOMText child?

Will every DOMElement always have at least one child, and in the case
of the DOMElement having one and only one child, will that child
always be a DOMText?

Basically, I need to know if elem->getChildNodes()->item(0) is
_always_ safe operation, and I furthermore know if I can rely on
item(0) always being a DOMText provided that
getChildNodes()->getLength() == 1.

Still learning the basics,
-Patrick

Reply via email to