dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: parsing questino

  1. #1
    Junior Member
    Join Date
    Oct 2001
    Posts
    7

    parsing question

    I am being fed an xml document of unknown structure and I need to look for a specific tag and then grap that tag's children. for example

    <espc>
    <agent>
    <txt> Sending flash </txt>
    </agent>
    <event><cmd> search-off</cmd></event>
    <agent>
    <cmd x="470" y="243">move</cmd>
    <cmd wait="1">wait</cmd>
    <cmd>GestureRight</cmd>
    </agent>
    <flash>
    <selection>Grainy</selection>
    <selection>Grains</selection>
    <selection>Draine</selection>
    <selection>Grainer</selection>
    <selection>Grained</selection>
    <selection>Gradine</selection>
    <selection>Grain</selection>
    <selection>Grane</selection>
    </flash>
    </espc>

    When I get this information I need to find the <flash> tag and grab what's between that and the </flash>. The information that will come before the <flash> tag will never be the same so the structure will always be different. So how do I go about parsing through the XML to find <flash> and then grab only the information between that and the </flash>
    thanks for your time.

  2. #2
    New Title:
    Join Date
    Jul 2002
    Posts
    87
    Well, you could do something like this:

    Code:
    // xmlTree is your XML document
    
    var n = xmlTree.firstChild;
    while (n) {
      if (n.nodeType == 1) {
        if (n.nodeName == "flash") {
          // here's your "flash" node
        }
      }
      n = n.nextSibling;
    }
    If you have multiple "flash" nodes, this will visit them all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center