1

I have Xml data coming from service and i wanted to read particular tag value of it. Following is my XML

    <data xmlns:string="http://symphony-cms.com/functions">
  <visa-requirements>
    <meta>
      <partner>itraveleo</partner>
      <nationality>India</nationality>
      <destination>India</destination>
      <type>business</type>
      <date-requested>2017-07-10 08:00 +01:00</date-requested>
      <data-available>1</data-available>
    </meta>
    <personal-application-only>0</personal-application-only>
    <visa-required>1</visa-required>
    <processing-time>3</processing-time>
    <documents>
      <item>Valid passport</item>
      <item>Business letter</item>
      <item>Official invitation</item>
      <item>2 passport photos</item>
      <item>
        <type>Application form</type>
        <method>download</method>
        <url>https://www.djbvisas.com/workspace/uploads/application_forms/india-authorisation-letter-529ca92d66fa4.docx</url>
      </item>
      <item>
        <type>Online application form</type>
        <method>link</method>
        <url>https://indianvisaonline.gov.in/visa/index.html</url>
      </item>
      <item>
        <type>Declaration form</type>
        <method>download</method>
        <url>https://www.djbvisas.com/workspace/uploads/application_forms/indian-declaration-5540f31d9c11d.pdf</url>
      </item>
    </documents>
    <embassy>
      <address-1>142-148 Goswell Road</address-1>
      <town>London</town>
      <postcode>EC1V 7DU</postcode>
      <phone>020 7836 8484</phone>
      <url>http://in.vfsglobal.co.uk/</url>
      <geo>51.5253588, -0.09938120000003892</geo>
    </embassy>
    <news>
      <article>
        <pubDate>2017-01-18</pubDate>
        <country>India</country>
        <country-flag>https://www.djbvisas.com/image/2/60/35/5/uploads/flag_images/inda0001-4ff4190f1faa2.gif</country-flag>
        <title>India Visa Charges</title>
        <url>https://www.djbvisas.com/news/1/34373/india-visa-charges/</url>
      </article>
      <article>
        <pubDate>2016-09-28</pubDate>
        <country>India</country>
        <country-flag>https://www.djbvisas.com/image/2/60/35/5/uploads/flag_images/inda0001-4ff4190f1faa2.gif</country-flag>
        <title>India Price Change</title>
        <url>https://www.djbvisas.com/news/1/27951/india-price-change/</url>
      </article>
    </news>
    <notes>Application form must be completed online 
2 utility bills needed one within the last three months and another which is 2 years old to date
Photos must be 50mm x  50mm

Visas can take 3-4 working days to obtain 
Same day processing is available 

In order to submit a visa application to India an appointment is now needed. To book an appointment please contact us.</notes>
  </visa-requirements>
</data>

I wanted to get value of tag. I tried by this

 var x = xmlDoc.getElementsByTagName('visa-required')[0];

I am getting error TypeError: xml.getElementsByTagName is not a function

Please help

RackM
  • 449
  • 7
  • 26
  • Possible duplicate of [How to parse XML using jQuery?](https://stackoverflow.com/questions/7228141/how-to-parse-xml-using-jquery) – xmojmr Jul 10 '17 at 07:14
  • What is xmlDoc? String? something received from AJAX? – Misaz Jul 10 '17 at 07:15
  • Thanks. @misaz. It's mentioned in question. – RackM Jul 10 '17 at 07:21
  • Thanks @xmojmr I am doing this in Angular 2 typescript so need to use javascript syntax. – RackM Jul 10 '17 at 07:23
  • It does not help. How Data arrived to the variable? For constructive help we need to know line of code which fill the xmlDoc variable. – Misaz Jul 10 '17 at 13:57

0 Answers0