Hi there,
I have an XML feed that contains multiple paths with the same name. Is there a way to tell AppleScript to go into the 3rd or 4th path of the same name.
See below XML feed. Is there a way to either tell AppleScript to return the player number 2 by telling AppleScript to go into the second XML element of <player> cause currently I can only return the first player because its the first <player> it comes across and enters into that folder path. Or can I search for the <player_no> that equals the number I want to return?
Here is my AppleScript
I have an XML feed that contains multiple paths with the same name. Is there a way to tell AppleScript to go into the 3rd or 4th path of the same name.
See below XML feed. Is there a way to either tell AppleScript to return the player number 2 by telling AppleScript to go into the second XML element of <player> cause currently I can only return the first player because its the first <player> it comes across and enters into that folder path. Or can I search for the <player_no> that equals the number I want to return?
Code:
<rugbymatch>
<home_players>
<player>
<player_id>3986</player_id>
<player_name>James Slipper</player_name>
<player_short>J. Slipper</player_short>
<surname>Slipper</surname>
<other_names>James</other_names>
<player_no>1</player_no>
<player_pos>LHP</player_pos>
</player>
<player>
<player_id>1038</player_id>
<player_name>Saia Fainga'a</player_name>
<player_short>S. Fainga'a</player_short>
<surname>Fainga'a</surname>
<other_names>Saia</other_names>
<player_no>2</player_no>
<player_pos>HOOK</player_pos>
</player>
<player>
<player_id>2173</player_id>
<player_name>Sekope Kepu</player_name>
<player_short>S. Kepu</player_short>
<surname>Kepu</surname>
<other_names>Sekope</other_names>
<player_no>3</player_no>
<player_pos>THP</player_pos>
</player>
</home_players>
</rugbymatch>
Here is my AppleScript
Code:
tell application "System Events"
set xmlData to contents of XML file "/xmlfile.xml"
tell XML element "rugbymatch" of xmlData
tell XML element "home_players"
tell XML element "player"
set homeKickerName to value of XML element "player_name"
end tell
end tell
end tell
end tell
end tell