XML : accessing value of XML file in javascript

I load an XML document using XMLHTTPRequest in my js file as below:

  <?xml version="1.0" encoding="utf-8"?>  <RMFSFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:xsd="http://www.w3.org/2001/XMLSchema">  <Host>www.example.com</Host>  <Port>8888</Port>     <Uri>www.example.com</Uri>  <Path>      <HD>          <UNC>path1</UNC>      </HD>      <SD>          <UNC>path2</UNC>      </SD>  </Path>    

I am trying to SELECT the value of "UNC" for HD using javascript.

I have tried something like below, which didn't work:

        var x = xml.getElementsByTagName('Path')[0];        var y = x.getElementsByTagName('HD');        var z = y.getElementsByTagName('UNC');    

Any idea How Can I retrieve the Path?

No comments:

Post a Comment