Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-21-2012, 03:10 PM   PM User | #1
tomystein
New Coder

 
Join Date: Nov 2011
Posts: 58
Thanks: 2
Thanked 0 Times in 0 Posts
tomystein is an unknown quantity at this point
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!
tomystein is offline   Reply With Quote
Old 03-21-2012, 04:15 PM   PM User | #2
tomystein
New Coder

 
Join Date: Nov 2011
Posts: 58
Thanks: 2
Thanked 0 Times in 0 Posts
tomystein is an unknown quantity at this point
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.
tomystein is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:21 AM.


Advertisement
Log in to turn off these ads.