XMLDOM Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George Jewell

    #1

    XMLDOM Question

    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

    #2
    Re: XMLDOM Question



    George Jewell wrote:

    [color=blue]
    > 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?[/color]

    You can check
    xmlDocument.get ElementsByTagNa me('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
    personalElement Object
    you can then check
    personalElement Object.getEleme ntsByTagName('M iddlename').len gth


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    Working...