Parsing XML on different server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doby48
    New Member
    • Feb 2008
    • 4

    Parsing XML on different server

    I have an html document and an XSLT currently. The XML that I need to parse is on a different remote server. Now, the XSLT works without issue as does the HTML document with XMLDOM if the XML file is hosted on the same server, however, when I try to call a remote file it doesnt work. Here is my HTML code with JS:

    Code:
    <head>
    <script>
    function getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
        }
      } 
      alert('Query Variable ' + variable + ' not found');
    }
    </script>
    </head>
    <html>
    <body>
    <script type="text/javascript">
    	var1 = getQueryVariable("var1");
    	var2 = getQueryVariable("var2");
    	vURL = 'http://xml.mywebserver.com/Userid=' + var1 + '&Password=' + var2;
    </script>
    
    <script type="text/javascript">
           var processor = new XSLTProcessor(); 
                var xslt = document.implementation.createDocument("", "", null); 
                xslt.async = false; 
                xslt.load("transform.xsl"); 
                processor.importStylesheet(xslt); 
    
                var src_doc = document.implementation.createDocument("","", null); 
                src_doc.async = false; 
                src_doc.load("http://xml.mywebserver.com"); 
                var result = processor.transformToDocument(src_doc); 
                var xmls = new XMLSerializer(); 
                var output = xmls.serializeToString(result); 
                document.write(output); 
            } 
    </script>
    </body>
    </html>
    Really, I need to use my variable vURL as the source document for the XML data as I need the variables passed through the URL. I tried using src_doc.load(vU RL) as well but still no go.
  • doby48
    New Member
    • Feb 2008
    • 4

    #2
    I guess I should say that for the record I am aware of the issue with javascript not working with cross domain functionality. However, I am know there are several work arounds for this (one be iframes which isnt an option in this case). And am wondering if someone can offer a solution as to a workaround or maybe 2-part solution, this being the second part just looking for maybe a GET functionality or something of the like or other workarounds people are familiar with.

    Comment

    • rnd me
      Recognized Expert Contributor
      • Jun 2007
      • 427

      #3
      there's (potentially) a few ways to do it without server-side scripting.
      i could likely be able to help if i knew a little more, i have a few ideas.


      can you control the content on both domains?

      can you place a whole file anywhere on the remote domain's server?

      what type of xml is it?

      does this need to work for just you, or do you need it to work for everyone?

      Comment

      Working...