Good afternoon,
I am trying to parse through an XML file with strictly Javascript (I would prefer to not use an add on such as jQuery because of memory constraints in the module this codes resides in). The XML file is populated by a module within a control system I have in an assembly line controller so I think the format is a little different that typical XML files. I can load the file correctly (I used an alert to see the raw text output and it is correct), but I can't load the value of the tag. A portion of the XML file loaded is below:
<tag name = "Parts_Built_Buffer[490].DateTime" valueType="cip:dt_STRINGI" path="1,0" access="read" display="String">
<value xsi:type="cip:dt_STRINGI">20140804110319</value>
</tag>
And it continues for 500 such tags... Every tag has a unique name due to the nature of the module requirements, so I want to loop through all the tags to get the values and build a table. For this my code (minus the loop part as I need to crawl (load 1 value) before I run (load all values)) is:
var builtDataView_url = "/user/system/dataviews/Parts_Built_Buffer.xml";
var getDataView = new XMLHttpRequest();
getDataView.open("GET", builtDataView_url, false);
getDataView.send();
var builtXML = getDataView.responseXML;
alert("response is " + getDataView.responseText)
var job0 = builtXML.getElementsByTagName("/tag[Name='Parts_Built_Buffer[0].DateTime']/value")[0];
alert("job0 is " + job0)
In the first alert I get a text view of the XML and it appears as expected. However, for job0 I get that it is undefined (if I alert job0.length I get 0). I need this to work in both Chrome and IE. Any advice will be greatly appreciated.
No comments:
Post a Comment