XMLDOM Question

Discussion in 'XML' started by George Jewell, Sep 10, 2004.

  1. 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.
    George Jewell, Sep 10, 2004
    #1
    1. Advertising

  2. 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


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 10, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Trip

    XMLHttpRequest + XMLDOM

    Trip, Oct 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    430
  2. Robert Zurer
    Replies:
    0
    Views:
    440
    Robert Zurer
    Jun 28, 2005
  3. Trip

    XMLHttpRequest + XMLDOM

    Trip, Oct 8, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    500
    intrader
    Oct 11, 2005
  4. Lamberti Fabrizio
    Replies:
    0
    Views:
    613
    Lamberti Fabrizio
    Jun 23, 2004
  5. Srini
    Replies:
    1
    Views:
    774
    Andy Fish
    Nov 25, 2003
Loading...

Share This Page