Re: Record-access command examples for XML parsing?
Re: Record-access command examples for XML parsing?
- Subject: Re: Record-access command examples for XML parsing?
- From: Daniel Sabsay <email@hidden>
- Date: Wed, 24 Apr 2002 10:00:01 -0700
Try:
on run
set XML_response to ,
{class:"XML document", XML_tag:"cpe_info", XML_contents:,
{,
{class:"XML element", XML_tag:"cpe_type",
XML_contents:{"DSL PPPoE Router"}}, ,
{class:"XML element", XML_tag:"cpe_manufacturer",
XML_contents:{"ABC Inc"}}, ,
{class:"XML element", XML_tag:"cpe_model",
XML_contents:{"PPPoE"}}, ,
{class:"XML element", XML_tag:"serial_number",
XML_contents:{"00012356B"}}, ,
{class:"XML element", XML_tag:"hardware_ver",
XML_contents:{"00009912"}}, ,
{class:"XML element", XML_tag:"software_ver",
XML_contents:{"001"}}, ,
{class:"XML element", XML_tag:"error_no",
XML_contents:{"0000000"}}, ,
{class:"XML element", XML_tag:"error_desc",
XML_contents:{"NO ERROR"}} ,
} ,
}
set element_list to XML_contents of XML_response
repeat with the_element in element_list
if (XML_tag of the_element = "cpe_model") then display dialog
XML_contents of the_element
end repeat
end run
On Wednesday, April 24, 2002, at 07:03 AM, email@hidden wrote:
I'm trying to pull out XML data using the XML Scripting Addition OSAX,
and finally got it to pull in data from my web-site. It comes back
looking like this:
{class:XML document, XML tag:"cpe_info", XML contents:{{class:XML
element, XML tag:"cpe_type", XML contents:{"DSL PPPoE Router"}},
{class:XML element, XML tag:"cpe_manufacturer", XML contents:{"ABC
Inc"}}, {class:XML element, XML tag:"cpe_model", XML
contents:{"PPPoE"}}, {class:XML element, XML tag:"serial_number", XML
contents:{"00012356B"}}, {class:XML element, XML tag:"hardware_ver",
XML contents:{"00009912"}}, {class:XML element, XML tag:"software_ver",
XML contents:{"001"}}, {class:XML element, XML tag:"error_no", XML
contents:{"0000000"}}, {class:XML element, XML tag:"error_desc", XML
contents:{"NO ERROR"}}}}
Here's where I get hung up. According to the notes for the XML parser,
"All elements of the returned structure can be accessed using standard
AppleScript record access techniques. Note that attributes are stored
as user properties. "
I'm having problems getting my syntax set up properly in Applescript
"record access" lingo. For instance, if I wanted to pull out the XML
data listed under "cpe_model", above, can someone tell me what
record-access command would do that?
- Rob
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
-- Daniel Sabsay
http://home.pacbell.net/sabsay/home
Cybernetic Moments
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.