I have some javascript in which I need to step through all the elements of some XML. An example of the XML is shown below:
<rules><and><eq propName="Unit1"/><gt propName="Unit2"/><or><startsWith propName="Test"/></or></and></rules>
I need check each part as I need to create objects based on the contents. Can someone supply a basic code framework that would allow me to examine this xml.
I have tried some code that calls itself but am getting confused on child nodes. Here is what I have so far (which doesn’t work).
load_rules_xml: function (value) {
var dom = $.xmlDOM(value);
this.add_rule_to_array(dom, null);
},
add_rule_to_array: function (xml, type) {
if (xml.length > 0) {
for (i = 0; i < xml.children.length; i++) {
var c = xml.children(i);
this.add_rule_to_array(c.children, null);
}
}
}