Javascript and DOM - navigating to specific TAG

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • primozr
    New Member
    • May 2007
    • 1

    #1

    Javascript and DOM - navigating to specific TAG

    Hi all,
    I am turning to this forum to get a little help for my non-profitable project. I am using javascript to parse some XML file.

    XML looks like this
    Code:
    <fdrml>
       <image>
          <faces>
             <face></face>
             <face></face>
             <face></face>
          </faces>
       </image>
       <results>
          <faces>
             <face></face>
             <face></face>
             <face></face>
          </faces>
       </resukts>
    </fdrml>
    what I want is to parse all "<face>" nodes in path "fdrml/images/faces". Now I do it using:
    Code:
    var xmlSource = getXML(file.xml);
    var sourceRoot = xmlSource.documentElement;
    
    face_list = sourceRoot.getElementsByTagName("Face")
    but this returns me all "<face>" nodes including those nodes in "fdrml/images/results/faces" path... I just want to get the list of nodes in from here "fdrml/images/faces"?

    Many thanks for your help,
    Primoz
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    See the XML DOM tutorial.

    See this ref. for parsing.

    Comment

    Working...