javascript - Loop Through XML Parse Function and Display in HTML -


I have a function that currently displays hard-coded XML data in an iPhone app;

  Function View XMLFiles () {xmlhttp = new XMLHttpRequest (); Xmlhttp.open ("GET", "TestInfo.xml", incorrect); Xmlhttp.send (); XmlDoc = xmlhttp.responseXML; Document.getElementById ("docname"). InnerHTML = xmlDoc.getElementsByTagName ("document_name") [0]. ChildNode [0] .nodeValue; Document.getElementById ("Filetype"). InnerHTML = xmlDoc.getElementsByTagName ("file_type") [0]. ChildNode [0] .nodeValue; Document.getElementById ("fileloc"). InnerHTML = pathToRoot + "/" + document.getElementById ("docname"). InnerHTML; Document.getElementById ("docname1"). InnerHTML = xmlDoc.getElementsByTagName ("document_name") [1]. ChildNode [0] .nodeValue; Document.getElementById ("filetype1"). InnerHTML = xmlDoc.getElementsByTagName ("file_type") [1] .childNodes [0] .nodeValue; Document.getElementById ("fileloc1"). InnerHTML = pathToRoot + "/" + document.getElementById ("docname1"). InnerHTML; }   

And I want to put it in a loop so that when I add the option of uploading the file the file will be automatically loop and click on a button while displaying the data. Instead of code it will be clicked on. Button is coded;

  & lt; Button onclick = "viewXMLFiles (); document.getElementById ('showDocumentLink'). Style.display = 'block';" & Gt; View Document Information & lt; / Button & gt; & Lt; Br>   

And the page is set to load XML in this form;

  & lt; Div id = "doclist" & gt; & Lt; H2 & gt; Document 1; & Lt; / H2 & gt; & Lt; Label & gt; Document name; & Lt; / Labels & gt; & Lt; Br> & Lt; Span id = "docname" & gt; & Lt; / Span & gt; & Lt; Br> & Lt; Label & gt; File type & lt; / Labels & gt; & Lt; Br> & Lt; Span id = "filetype" & gt; & Lt; / Span & gt; & Lt; Br> & Lt; Label & gt; File Location & lt; / Label & gt; & Lt; Br> & Lt; Span id = "fileloc" & gt; & Lt; / Span & gt; & Lt; Br> & Lt; / Div & gt; & Lt; Div id = "doclist" & gt; & Lt; H2 & gt; Document 2; & Lt; / H2 & gt; & Lt; Label & gt; Document name; & Lt; / Labels & gt; & Lt; Br> & Lt; Span id = "docname1" & gt; & Lt; / Span & gt; & Lt; Br> & Lt; Label & gt; File type & lt; / Labels & gt; & Lt; Br> & Lt; Span id = "filetype1" & gt; & Lt; / Span & gt; & Lt; Br> & Lt; Label & gt; File Location & lt; / Label & gt; & Lt; Br> & Lt; Span id = "fileloc1" & gt; & Lt; / Span & gt; & Lt; Br> & Lt; / Div & gt;   

I'm really new to XML files and how to parse them for using Javascript, so there is some help in showing me that they for The loop is great. I do not really know how to do it, so any help would be greatly appreciated. Thanks in advance :)

Try it ....

  XmlDoc = $ .parseXML (xml), $ xml = $ (xmlDoc), $ title = $ xml.find ("document_name"); . $ ("# DOCNAME") enclosed ($ title.text ());    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -