I’m not sure I understand what the question is or what you are asking. Plus, the second line of code will not complie on my machine running Panther.
set xml_source to ((path to desktop) as string) & "login.xml"
set xml_data to parse XML (read file xml_source)
this will and it will read the file...
set xml_source to ((path to desktop) as string) & "login.xml"
set xml_data to (read file xml_source)
What are you trying to get AppleScript to do for you?
Yeah, it works if I add put it in the script it self, but I want to read it from an external file, then parse it. And I get an errror while trying to parse the read file.
Oh wait…let me try reading each paragraph rather than simply reading it. Hrmm, won’t be able to get to it 'til after the holidays though. Will be in Vegas.
Let me know if you can get it to work with an external file.
Thanks a ton,
-Rob
p.s. My question was: How can I get it to read an XML doc then parse the info? I’m getting the afforementioned error.
Aha. I see what the problem is. My XML code is fine. The doctype is automatically generated on output, so you don’t need to actually include it in your xml file, and for some reason, the parser wants a parent for the whole document.
Should be:
<?xml version="1.0" encoding="iso-8859-1">
However, doctype automatically generated, and since it wants a parent for the entire document, I can just use:
Thanks for the help,
-Warhaven
It’s parsing everything fine, but I can’t seem to extract the values from it. I looked around for someone else with this problem, but couldn’t seem to find any helpful info. So, would someone help me with this quick bit?
Here’s what I have:
on awake from nib theObject
set xml_source to ((path to desktop) as string) & "login.xml"
set xml_data to parse XML (read file xml_source)
repeat with myElement in XML contents of xml_data
if XML tag of anItem is "account" then
display dialog |name| of myElement as string
end if
end repeat
end awake from nib
Just a little script to pop up a window and show the value of |name|. Here’s the XML doc it’s reading from: