XMLDOM Question

George Jewell

Usenet Archive
Joined
Oct 3, 2001
Messages
2
Reaction score
0
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.
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
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
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top