XMLDOM Question

G

George Jewell

Hello,

I have a block of xml and need to determine if a specific element exists.
(Using IE 6).

I might have the following:

<Results>
<Personal>
<Lastname>Doe</Lastname>
<Firstname>John</Firstname>
<Middlename>Q</Middlename> (this element may or may not exist,
depending on the results)
</Personal>
</Results>

Using the XMLDOM, is there a property or method I can use to determine if,
say, the <Middlename> element even exists in the block?

Thanks.
 
M

Martin Honnen

George Jewell wrote:

I have a block of xml and need to determine if a specific element exists.
(Using IE 6).

I might have the following:

<Results>
<Personal>
<Lastname>Doe</Lastname>
<Firstname>John</Firstname>
<Middlename>Q</Middlename> (this element may or may not exist,
depending on the results)
</Personal>
</Results>

Using the XMLDOM, is there a property or method I can use to determine if,
say, the <Middlename> element even exists in the block?

You can check
xmlDocument.getElementsByTagName('Middlename').length
to find out how many elements with the tag name 'Middlename' exist.
If you have a certain element already you can also appy that method to
the element say you have
personalElementObject
you can then check
personalElementObject.getElementsByTagName('Middlename').length
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top