Skip to main content
Participating Frequently
August 1, 2006
Question

Parsing XML File in Bridge

  • August 1, 2006
  • 5 replies
  • 1094 views
hi,

I have build a navbar in bridge with html. Within the html file I need to parse an xml document, to get some global preferences.
But the problem is accessing XML via Javascript DOM.
I have this scripts that on normal html pages do always work:

var xmlDoc
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject){
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("./globals/preferences.xml");
readXML();
}
//code for Mozilla, etc.
else if (document.implementation && document.implementation.createDocument){
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("./globals/preferences.xml");
xmlDoc.onload=readXML;
}
else{
alert('Your browser cannot handle this script');
}

}

function readXML(){

alert(xmlDoc.getElementsByTagName("value")[0].firstChild.nodeValue);

}

But within bridge I always get the else alert.
Is there no XML accessibility via DOM in bridge. What esle can I use, XPath (which I have never used before :-(?

Operating Sytem: W-XP

Greetings from Cologne, Germany
Markus
This topic has been closed for replies.

5 replies

August 6, 2006
That's really great to hear!!

Thank you!

Bob
Participating Frequently
August 6, 2006
Thanx a lot Bob!

Finally I made it :) and being a beginner learned a lot with your script collection. This makes xml reading and writing really easy...

Markus
August 3, 2006
Markus,

Here's a cheezy little XML parser I wrote.

It doesn't handle namespaces or PCDATA, but it will parse simple xml, returning a XmlNode object that points to the root of the XML doc.

Look at the XmlNode class and the XMLParser object to figure out how to use it.

http://rstucky.mystarband.net/XmlParser.jsx

Bob
Participating Frequently
August 3, 2006
hi xbytor,<br /><br />thanx for the tip. The framework seems to quite usefull, but I can't really get along with it :(<br /><br />As I understand it, I have to build a new kind of xml data with <<tag>> instead of <tag> and I have to rename the file back to html to load it. This would be bad, because I am not the creator of the xml file, which I have to load.<br />I mad it to load a file and to get the hole quoted content, but then there was no way to parse the single tags anymore (?????).<br /><br />Maybe you could be so kind, to post a few lines of code, where I could see, how you would load a file "pref.xml" which contains the following structure and how you would get the value string out of it:<br /><br /><prefs><br /><tag1><br />value<br /></tag1><br /></prefs><br /><br />Maybe if I see the solution for this simple example, I understand the procedure better...<br /><br />Thanks for any help<br /><br />markus
Known Participant
August 1, 2006
Markus_Selbach@adobeforums.com wrote:
> But within bridge I always get the else alert.
> Is there no XML accessibility via DOM in bridge. What esle can I use, XPath (which I have never used before :-(?

I use:
xmlsax.js
xmlw3cdom.js
xmlpath.js
These are a set of files from the project at http://xmljs.sourceforge.net.

-X

--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com