This may seem trivial, but I can't figure it out how to 1) retrieve the XML data and 2) find specific content within a child element with this specific XML structure!
XML:
<UploadResults>
<Header>
<Header_ID>1</Header_ID>
<PlanYear>2015</PlanYear>
<PlanVersion>FP01</PlanVersion>
</Header>
<ErrorSet>
<Row>
<Row_Id>0</Row_Id>
<Error_String>Validation successful with Zero Errors</Error_String>
</Row>
<Row>
...
</Row>
</ErrorSet>
</UploadResults>
My code:
$.ajax({
type: "GET",
url: "testurl",
dataType: "xml",
success: function(xml) {
$(xml).find('UploadResults').each(function(){
var errMsg = $(this).find('Error_String').text(); // set variable as content in child 'Error_String'
$(".validationView").append($(this).text()); // display all xml data on div class
if (errMsg=="Validation successful with Zero Errors") {
$("span.proceedBTN").show();
}
});
}
});
The script works with the following XML Structure so I am not sure why the script doesn't return any data from the first xml structure. (Of course, I would change the root name from UploadResults to Rowsets)
<Rowsets>
<Rowset>
<Columns>
<Column Description="Header_Id"/>
<Column Description="PlanYear"/>
<Column Description="PlanVersion"/>
</Columns>
<Row>
<Row_Id>0</Row_Id>
<Error_String>Validation successful with Zero Errors</Error_String>
</Row>
<Row>
...
</Row>
</Rowset>
</Rowsets>