xml-featured-image
in ,

Few XML Helpers to deal in Typescript

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

PREM KUMAR
PREM KUMAR
Hey Its..! Tech Lover , Ionic, Angular, Typescript, Dotnet Core, Node, Like Opencv, AI, ML, Robotics, Iot, Love Music, Cooking, Girls, Innovation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

What do you think?

400 Points
Upvote Downvote

How do I access my SSH public key on mac?

How effectively we can use temporary tables in Oracle?