XML/XPath: Difference between revisions

Content added Content deleted
Line 70: Line 70:
''AppleScript has no-built in support for XPath, but it could be used via a 'do shell script' command. Here's a solution using Apple System Events.
''AppleScript has no-built in support for XPath, but it could be used via a 'do shell script' command. Here's a solution using Apple System Events.


Unfortunately, System Events cannot accomplish the first goal, but it can be used to accomplish the final two:''
Unfortunately, System Events cannot accomplish the first goal, but it's XML Suite can help to accomplish the final two:''


<lang AppleScript>on getElementsByName(theElement, theNameToFind)
<lang AppleScript>on getElementsByName(theElement, theNameToFind)
Line 76: Line 76:
repeat with i in theElement
repeat with i in theElement
tell application "System Events"
tell application "System Events"
set {theName, theAttributes, theElements} to {i's name, {}, i's XML elements}
set {theName, theElements} to {i's name, i's XML elements}
try
try
set theValue to i's value
set theValue to i's value
Line 125: Line 125:
return my getElementsByName(xmlData's contents, "price")
return my getElementsByName(xmlData's contents, "price")
--> {"14.50", "23.99", "4.95", "3.56"}
--> {"14.50", "23.99", "4.95", "3.56"}
end
end</lang>
</lang>


=={{header|C sharp}}==
=={{header|C sharp}}==