using XML data in DesktopX

most likely a stupid question...

Hi,

I want to call some data from a xml file...

my script doesn't give me errors which is a good start  but there is no data pulled out of my xml-file...

 //writing to the buttons on the welcome page
 var xmlDoc=null;
 xmlDoc= new ActiveXObject("Microsoft.XMLDOM");
 
 if(xmlDoc!=null){
 xmlDoc.async=false;
 xmlDoc.load("C:/Documents and Settings/Administrator/My Documents/Stijn/fileloc.xml");
 file=xmlDoc.getElementsByTagName("file");
 
 for(i=0;i<=5;i++){
    if (i<file.length){
       DesktopX.Object("choice"+i).visible=1;
       DesktopX.Object("choice"+i).text= file[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;}
    else DesktopX.Object("choice"+i).visible=0;
 }
 }

does somebody knows what is going wrong??

& is there a way to make relative links??

 

thanks!!!!

 

4,047 views 6 replies
Reply #1 Top
Your file path looks wrong. Change to a backslash and not a forward slash.
Reply #2 Top
my filepath did worked before (on other places of my desktop)
single backslashes will be processed as :
C:Documents and SettingsAdministratorMy DocumentsStijnfileloc.xml

the alternatives are:
with slashes (works in most cases!)
C:/Documents and Settings/Administrator/My Documents/Stijn/fileloc.xml

or double backslashes:
C:\\Documents and Settings\\Administrator\\My Documents\\Stijn\\fileloc.xml
(will be processed as : C:\Documents and Settings\Administrator\My Documents\Stijn\fileloc.xml

It most be something else... don't now what :-( and nobody seems to know the answer...

greetz

;-)
Reply #3 Top
Somebdoy??
Anybody??

Even an example on how to get data from a local xml file in VBScript could help me out...
This most be possible in desktopx... isn't it??
Reply #4 Top
I have a different method of getting XML data, and i just tried to make a simple object that reads a local file and outputs the TITLE/DESCRIPTION from it to the object.

'Called when the script is executed
Sub Object_OnScriptEnter
URL = "file:///D:/My%20Data/My%20Documents/QueueRSS.xhtml"
Set http = CreateObject("Microsoft.XmlHttp")
http.Open "GET", URL, False
http.send ""
RssData = http.responseText
ItmCount = 0
countstart = 1
Do While countstart <> 0
countstart = Instr(countstart, RssData, "
Reply #5 Top

I thought i got some more experience with xml... but my new code end with status =0

Code: javascript
  1. var WSH= new ActiveXObject("WScript.Shell");
  2. var allusers= WSH.Environment("PROCESS")("ALLUSERSPROFILE");
  3. allusers+="<a href="file://\\XML">\\XML</a>";
  4. var xmlDoc;
  5. //Called when the script is executed
  6. function Object_OnScriptEnter(){
  7.  screenreset();
  8.  Scan();
  9.  Object.Comments = folders.length;
  10. loadXMLDoc(allusers+"<a href="file://\\pet.xml">\\pet.xml</a>");
  11. }
  12. function loadXMLDoc(url)
  13. {
  14. xmlDoc=null;
  15. xmlDoc=new ActiveXObject("Microsoft.XMLHTTP");
  16. if (xmlDoc!=null)
  17.   {
  18.   xmlDoc.onreadystatechange=onResponse;
  19.   xmlDoc.open("GET",url,false);
  20.   xmlDoc.send(null);
  21.   }
  22. }
  23. function onResponse(){
  24. if(xmlDoc.readyState!=4) return;
  25. if(xmlDoc.status!=200)
  26.   {
  27.   WSH.Popup(xmlDoc.status,0,"Error",0+48);
  28.   return;
  29.   }
  30. var file=xmlDoc.responseXML.documentElement.getElementsByTagName("pet");
  31. for(i=0;i&lt;=5;i++){
  32.   if (i&lt;file.length){
  33.        DesktopX.Object("choice"+i).visible=1;
  34.        DesktopX.Object("choice"+i).text= file[i].getElementsByTagName("state")[0].firstChild.nodeValue;}
  35.     else DesktopX.Object("choice"+i).visible=0;
  36.  }
  37.  }

Somebody out there who can help me?

Reply #6 Top

To all people intrested: I found the soultion myself, (thanks google :sun: )

 

Code: javascript
  1. xmlDoc=null;
  2. xmlDoc=new ActiveXObject("Microsoft.XMLHTTP");
  3. xmlDOM=new ActiveXObject("Microsoft.XMLDOM");
  4. if (xmlDoc!=null &amp;&amp; xmlDOM!=null)
  5.   {
  6.   xmlDoc.onreadystatechange=onResponse;
  7.   xmlDoc.open("GET",url,false);
  8.   xmlDoc.send(null);
  9.   }
  10. }
  11. function onResponse(){
  12. if(xmlDoc.readyState!=4) return;
  13. var xmlstring=xmlDoc.responsetext;
  14. xmlDOM.async=false;
  15. xmlDOM.loadXML(xmlstring);
  16. var file=xmlDOM.getElementsByTagName("pet");
  17. for(i=0;i&lt;=5;i++){
  18.   if (i&lt;file.length){
  19.        DesktopX.Object("choice"+i).visible=1;
  20.        DesktopX.Object("choice"+i).text= file[i].getElementsByTagName("date")[0].childNodes[0].nodeValue;}
  21.     else DesktopX.Object("choice"+i).visible=0;
  22.  }
  23.  }

Combining both XMLHTTP & XMLDOM does the trick! ;-)

for some reason in desktopx the XMLHTTP responseXML and the function load of XMLDOM aren't supported