I've got a script I'm trying to setup that communicates over a socket to retrieve different directions from a custom built Java program. The Java program listens to requests from the Adobe scripting engine (in my case it's a Photoshop script) on a socket and immediately responds with the next set of directions. These directions are currently in XML format. The issue I'm having is that I can't parse the XML data since it's entered into a new XML object from a string rather than being read from a file. Even without the socket code, you can see the issue by doing the following:
var xml = new XML("<test><data>hey!</data></test>"); alert(xml.test.data); alert(xml);
The first alert "should" return "hey!" (without quotes, of course), but it doesn't, while the second alert returns what you would expect it to:
<test> <data>hey!</data> </test>
It works fine if read from an XML file, but from a string, like shown above, it just presents an empty alert box when attempting to access "xml.test.data". Any ideas on how to fix this issue? Can it be fixed? Has it been fixed in newer versions (I'm currently using CS4)?
Thanks in advance for any help!
Duh... found my error... I was attempting to access the data by referencing the created "root" element. Since <test> is the very first element tag, it's setup as the root element, which you don't need to reference. Changing the alert to alert(xml.data); fixed it.
Now I just feel dumb, lol...