You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Nicolas Tsokas <ts...@ekt.gr> on 2008/01/25 12:06:10 UTC

Element's descendant with name...?

Hello all,

 

I'm trying to figure if a certain element <myelement> has any (at least one)
descendant with name <mydescendant>. 

 

For example:

 

<myelement>

            <mychildelement/>

            <myotherchildelement/>

            <mydescparent>

                        <mydescendant/>

            </mydescparent>

</myelement>

 

. would yield TRUE for <myelement>.

                        

If there is no such method, I could take the XML text (the portion of the
XML document) corresponding to <myelement> and then look for a regular
expression like "<mydescendant[ >]" (where brackets include a SPACE and a
GREATER_THAN sign).

 

.but I can't figure out how I can get the XML text either.

 

Somebody can help?

 

Thank you

 

Nicolas Tsokas, National Hellenic Research Foundation

 


RE: Element's descendant with name...?

Posted by Nicolas Tsokas <ts...@ekt.gr>.
Thanks Jesse, 

I was by mistake only looking at DOMNode's methods and not DOMElement's... 

Nicolas

__________________________
-----Original Message-----
From: Jesse Pelton [mailto:jsp@PKC.com] 
Sent: Friday, January 25, 2008 1:59 PM
To: c-dev@xerces.apache.org
Subject: RE: Element's descendant with name...?

Assuming you're working with a DOM, you can use
DOMElement::getElementsByTagName().  It will return a list that includes any
descendant elements with the specified name.


-----Original Message-----
From: Nicolas Tsokas [mailto:tsokas@ekt.gr]
Sent: Fri 1/25/2008 6:06 AM
To: c-dev@xerces.apache.org
Subject: Element's descendant with name...?
 
Hello all,

 

I'm trying to figure if a certain element <myelement> has any (at least one)
descendant with name <mydescendant>. 

 

For example:

 

<myelement>

            <mychildelement/>

            <myotherchildelement/>

            <mydescparent>

                        <mydescendant/>

            </mydescparent>

</myelement>

 

. would yield TRUE for <myelement>.

                        

If there is no such method, I could take the XML text (the portion of the
XML document) corresponding to <myelement> and then look for a regular
expression like "<mydescendant[ >]" (where brackets include a SPACE and a
GREATER_THAN sign).

 

.but I can't figure out how I can get the XML text either.

 

Somebody can help?

 

Thank you

 

Nicolas Tsokas, National Hellenic Research Foundation

 




---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


RE: Element's descendant with name...?

Posted by Jesse Pelton <js...@PKC.com>.
Assuming you're working with a DOM, you can use DOMElement::getElementsByTagName().  It will return a list that includes any descendant elements with the specified name.


-----Original Message-----
From: Nicolas Tsokas [mailto:tsokas@ekt.gr]
Sent: Fri 1/25/2008 6:06 AM
To: c-dev@xerces.apache.org
Subject: Element's descendant with name...?
 
Hello all,

 

I'm trying to figure if a certain element <myelement> has any (at least one)
descendant with name <mydescendant>. 

 

For example:

 

<myelement>

            <mychildelement/>

            <myotherchildelement/>

            <mydescparent>

                        <mydescendant/>

            </mydescparent>

</myelement>

 

. would yield TRUE for <myelement>.

                        

If there is no such method, I could take the XML text (the portion of the
XML document) corresponding to <myelement> and then look for a regular
expression like "<mydescendant[ >]" (where brackets include a SPACE and a
GREATER_THAN sign).

 

.but I can't figure out how I can get the XML text either.

 

Somebody can help?

 

Thank you

 

Nicolas Tsokas, National Hellenic Research Foundation