Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How do you import an external xml?

    I want to design an xml with xls but I am stuck because I can't connect the xls to an external xml.

    Do you have an example that works? didn't see anything on W3 but maybe I am wrong.

    Many thanks!

  • #2
    New Coder
    Join Date
    Nov 2011
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This is the code where I am trying to add an external XML:

    PHP Code:
    <html>
    <
    head>
    <
    script>
    function 
    loadXMLDoc(dname)
    {
    if (
    window.XMLHttpRequest)
      {
      
    xhttp=new XMLHttpRequest();
      }
    else
      {
      
    xhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xhttp.open("GET",dname,false);
    xhttp.send("");
    return 
    xhttp.responseXML;
    }

    function 
    displayResult()
    {
    xml=loadXMLDoc("movies.xml");
    xsl=loadXMLDoc("movies.xsl");
    // code for IE
    if (window.ActiveXObject)
      {
      
    ex=xml.transformNode(xsl);
      
    document.getElementById("example").innerHTML=ex;
      }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument)
      {
      
    xsltProcessor=new XSLTProcessor();
      
    xsltProcessor.importStylesheet(xsl);
      
    resultDocument xsltProcessor.transformToFragment(xml,document);
      
    document.getElementById("example").appendChild(resultDocument);
      }
    }
    </script>
    </head>
    <body onload="displayResult()">
    <div id="example" />
    </body>
    </html> 
    I thought I can change this line:

    PHP Code:
    xml=loadXMLDoc("movies.xml"); 
    into:

    PHP Code:
    xml=loadXMLDoc("http://www.example.com/feed/"); 

    But it doesn't work.

    Also couldn't do it with something like this. Just because I am having mistakes with the way I am writing it.

    PHP Code:
    string url "http://example.com/feed/";
    WWW www = new WWW(url);
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(www.data); 
    Thanks in advance.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •