Wayne,
You’re looking for XPATH To answer your example, getting the preferredUsername, using XPATH would be: <@ELEMENTVALUE myDom xpath=’//preferredUsername’> That tag will return the content of the node named ‘preferredUsername’ from anywhere in the document. You can also be specific (from root) if need be: <@ELEMENTVALUE myDom xpath=’/rsp/profile/preferredUsername’> Here’s a list of some more useful XPATH syntax: http://www.w3schools.com/xpath/xpath_syntax.asp Robert From: Wayne Irvine [mailto:[email protected]] Sent: Thursday, July 11, 2013 1:50 AM To: [email protected] Subject: TeraScript-Talk: XML/JSON I haven't played with XML in ages and JSON seems to be the flavour of the month these days so I'll include it in the discussion. I using a Social Media authentication service (Janrain) that returns some data from whatever social media type the user decides to log in with. It can return this data as JSON or XML (and possibly others). An XML return from Facebook looks like this: <![CDATA[<?xml version='1.0' encoding='UTF-8'?> <rsp stat='ok'> <profile> <providerName>Facebook</providerName> <identifier>http://www.facebook.com/profile.php?id=6297357315 <http://www.facebook.com/profile.php?id=6297357315%3c/identifier%3e> </identifier> <verifiedEmail>[email protected] <mailto:[email protected]> </verifiedEmail> <preferredUsername>WayneIrvine</preferredUsername> <displayName>Wayne Irvine</displayName> <name> <formatted>Wayne Irvine</formatted> <givenName>Wayne</givenName> <familyName>Irvine</familyName> </name> <email>[email protected] <mailto:[email protected]> </email> <url>http://www.facebook.com/wayne.irvine <http://www.facebook.com/wayne.irvine%3c/url%3e> </url> <photo>https://graph.facebook.com/629357315/picture?type=large <https://graph.facebook.com/629357315/picture?type=large%3c/photo%3e> </photo> <utcOffset>10:00</utcOffset> <address> <formatted>Sydney, Australia</formatted> <type>currentLocation</type> </address> <birthday>1968-08-23</birthday> <gender>male</gender> <providerSpecifier>facebook</providerSpecifier> </profile> <limited_data>false</limited_data> </rsp>]]> I assign that to a DOM "myDom". Now I would like to use a specific value within that set, for example, the <preferredUsername>. The documentation seems to suggest I should use a structured count like: <@ELEMENTNAME OBJECT="myDom" XPOINTER="root().child(1).child(4)"> This seems anathema to me as surely the structure should be able to change and as long as the names remain the same it would return the correct value. Something like: <@ELEMENTNAME OBJECT="myDom" CHOSEVALUE="profile.preferredUsername"> Is this not the case? Wayne Irvine w: http://www.byteserve.com.au/ p: +61 2 9960 6099 m: 0409 960 609 _____ To unsubscribe from this list, please send an email to [email protected] <mailto:[email protected]> with "unsubscribe terascript-talk" in the body. ---------------------------------------- To unsubscribe from this list, please send an email to [email protected] with "unsubscribe terascript-talk" in the body.
