Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Parsing XML File in Bridge

New Here ,
Aug 01, 2006 Aug 01, 2006
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
TOPICS
Scripting
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 01, 2006 Aug 01, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 03, 2006 Aug 03, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2006 Aug 03, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 06, 2006 Aug 06, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 06, 2006 Aug 06, 2006
LATEST
That's really great to hear!!

Thank you!

Bob
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines