In this example we explain that how to Read and Parse XML Web Resource in Dynamic CRM using JavaScript. Or how to Read and Parse XML Web Resource using XRM in Dynamic CRM.Or how to read XML file in Dynamic CRM using JavaScript and XRM.
So here we demonstrate
that how to read XML web Resource and Parse using JavaScript in Dynamic
365.below is the XML Web Resource file and JavaScript code that will read and
parse XML file using JavaScript and XRM in Dynamic CRM.
<?xml version="1.0"
encoding="utf-8" ?>
<Fruits>
<Fruit Code="App">
<Name>Apple</Name>
<Price>20</Price>
</Fruit>
<Fruit Code="Orng">
<Name>Orange</Name>
<Price>10</Price>
</Fruit>
</Fruits>
function ReadXML() {
try
{
var
xmlPath = "../WebResources/new_fruitsxml";
$.ajax({
type: "GET",
url: xmlPath,
dataType: "xml",
success: parseXML
});
} catch
(e) {
alert("Error
while reading XML; Description – " + e.description);
}
}
function
parseXML(xml) {
$(xml).find("Fruit").each(function
() {
//
Read attribute
alert("Fruit
Code – " + $(this).attr("Code"));
//
Read Nodes
alert("Fruit
Name – " + $(this).find("Name").text());
alert("Fruit
Price – " + $(this).find("Price").text());
});
}
0 comments:
Post a Comment