Hi everyone here I am introducing some code to deal with xml data in javascript.
// XML Helpers..
getXmlTagValue(xmlString: string, TagName: string): any {
const xmlDocument = (new DOMParser()).parseFromString(xmlString, 'application/xml');
const tagValue = xmlDocument.getElementsByTagName(TagName)[0].childNodes[0].nodeValue;
return tagValue;
}
getXmlTagList(xmlString: string, TagName: string): any {
const xmlDocument = (new DOMParser()).parseFromString(xmlString, 'application/xml');
const tagList = xmlDocument.getElementsByTagName(TagName);
return tagList;
}
getElementsValueByTagName(Element: any, TagName: string): any {
try {
const ElementValue = Element.getElementsByTagName(TagName)[0];
return ElementValue;
} catch (error) {
}
}
Author Profile
- Hey Its..! Tech Lover , Ionic, Angular, Typescript, Dotnet Core, Node, Like Opencv, AI, ML, Robotics, Iot, Love Music, Cooking, Girls, Innovation