Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.7 kB
0
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=<p ProductName="çay" UnitPrice="12121.0000">
        
    <title>Document</title>
</head>
<body>
    <pre id="myXML"></pre>
    <script>

        var xmlText, xmlParser, xmlObject;
        xmlText=
        "<Products>"+
            "<Product>"+
              "<ProductName>çay</ProductName>"+
              "<CategoryName>Beverages</CategoryName>"+
              "<UnitPrice>12121.0000</UnitPrice>"+
           "</Product>"+
            "<Product>"+
              "<ProductName>Telefon</ProductName>"+
              "<CategoryName>Electronic</CategoryName>"+
              "<UnitPrice>5000.0000</UnitPrice>"+
            "</Product>"+
            "<Product>"+
              "<ProductName>Côte de Blaye</ProductName>"+
              "<CategoryName>Beverages</CategoryName>"+
              "<UnitPrice>263.5000</UnitPrice>"
            "</Product>"+
          "</Products>";
          xmlParser = new DOMParser();
          xmlObject= xmlParser.parseFromString(xmlText,"text/xml");
          for (var i=0;i<3;i++){
            document.getElementById('myXML').innerHTML+=xmlObject.getElementsByTagName("ProductName")[i].childNodes[0].nodeValue+"<br/>";
            document.getElementById('myXML').innerHTML+=xmlObject.getElementsByTagName("CategoryName")[i].childNodes[0].nodeValue+"<br/>";
            document.getElementById('myXML').innerHTML+=xmlObject.getElementsByTagName("UnitPrice")[i].childNodes[0].nodeValue+"<br/>";
          }
          
    

    </script>
    
    
</body>
</html>