Classic ASP Loop Through XML -


I have an XML payload like

   & Lt; Projects & gt; & Lt; Project ID = "Project 1-ID" name = "Project 1-name" /> & Lt; Project ID = "Project 2-ID" name = "Project 2-name" /> & Lt; / Projects & gt; & Lt; / Site & gt; & Lt; Site id = "site2-id" name = "site2-name" contentUrl = "site2-content-url" /> & Lt; Projects & gt; & Lt; Project ID = "Project 3-ID" name = "Project 3-name" /> & Lt; Project ID = "Project 4-ID" name = "project-4-name" /> & Lt; / Projects & gt; & Lt; / Site & gt; & Lt; / Sites & gt; & Lt; / TsResponse & gt;  

I can loop through each site, collecting every site id, name and contentURL, as I go with the following

  OXML set = Server.CreateObject ( "Microsoft.XMLDOM") oXML.LoadXML (postResponse) 'sXML) Sid = oNode.GetAttribute ( "/ tsResponse / sites / site oXML.SelectNodes content of your XML file for each oNode "(" id "containing a variable) SNAME = oNode.GetAttribute (" name ") sContentURL = oNode.GetAttribute (" contentUrl ") Next set oXML = nothing  

although How do each project ID and name take place within each site? Do I need to be existing for an existing loop or is it very disabled? Where is a special feature = x?

update

  do I loop through ( "/ tsResponse / sites oXML.SelectNodes for each oNode / site") Sid = oNode.GetAttribute ( "ID") SNAME = oNode .GetAttribute ("name") sContentURL = oNode.GetAttribute ("contentUrl") Response.Write ("& LT; H2 & gt; "& Amp; SNAME & amp; / "& Amp; Sid & amp; / "& Amp; ContentContentURL & amp; & Lt; / H2 & gt; ") [Each oNode (the" / TsResponse / sites / site in oXML.SelectNodes @id = '' & amp; Sid & amp; " '] / Projects / Project") PID = oNode.GetAttribute ( "ID ") pName = oNode.GetAttribute (" name ") Response.Write (" & LT; h3 & gt; "& amp; PID & amp;" / "& amp; pName & amp;" & lt; / h3 & gt; ") Next set oXML = nothing  

second to loop I 'loop control variable for the' code 'invalid'

The oNode has been changed to oNode2 and it works!

  in oXML for each onode .SelectNodes ("/ tsResponse / sites / site") SID = oNode.GetAttribute ("id") SNA me = onod.getAttribute ("name") sContentURL = oNode.GetAttribute ("contentUrl") Response. Written ("& lt; h2 & gt;" & amp; Name and / "And select SID and /" & amp; amp; Content URL  ") for each ON2.2 in OXX (select" / tsResponse / site / site [@id = PID = oNode2.GetAttribute ("id") PName = oNode2.GetAttribute ("name") Response.write ("& lt; h3>"; & amp; "; & Amp; PID & amp; & Quot; & amp; P & amp; Name & amp;; & lt; / h3 & gt; ") Next Next Set oXML = None  / Pre> 

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -