External Data XPath demo: Difference between revisions

From Discourse DB
Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:
|format=xml
|format=xml
|use xpath
|use xpath
|data=salutation=/letter/salutation,maxlength=/letter/title[2]/@maxlength,address=/letter/address[@translate='no'],url=/letter/weblink}}
|data=salutation=/letter/salutation,maxlength=/letter/title[2]/@maxlength,address=/letter/address[@translate='no'],url=/letter/weblink,logoalt=/letter/logo/@alt,x=y
</pre>
</pre>
{{#get_web_data:url=http://producthelp.sdl.com/SDL%20Trados%20Studio/client_en/sample.xml
{{#get_web_data:url=http://producthelp.sdl.com/SDL%20Trados%20Studio/client_en/sample.xml
|format=xml
|format=xml
|use xpath
|use xpath
|data=salutation=/letter/salutation,maxlength=/letter/title[2]/@maxlength,address=/letter/address[@translate='no'],url=/letter/weblin,logoalt=logo/@alt
|data=salutation=/letter/salutation,maxlength=/letter/title[2]/@maxlength,address=/letter/address[@translate='no'],url=/letter/weblink,logoalt=/letter/logo/@alt,x=y
k}}
k}}
Note: the trailing "x=y" has been added as a workaround for a bug.


'''Salutation:''' {{#external_value:salutation}}
'''Salutation:''' {{#external_value:salutation}}

Revision as of 11:09, October 25, 2012

The following is a demonstration of the "use xpath" feature of the External Data extension, to get specific values from the XML using XPath notation.

Data is retrieved from this sample XML file, using the following call:

{{#get_web_data:url=http://producthelp.sdl.com/SDL%20Trados%20Studio/client_en/sample.xml
|format=xml
|use xpath
|data=salutation=/letter/salutation,maxlength=/letter/title[2]/@maxlength,address=/letter/address[@translate='no'],url=/letter/weblink,logoalt=/letter/logo/@alt,x=y

Error: "y k" is not valid XPath ($3).

Note: the trailing "x=y" has been added as a workaround for a bug.

Salutation: Error: no local variable "salutation" has been set.

Max length: Error: no local variable "maxlength" has been set.

Address: Error: no local variable "address" has been set.

URL: Error: no local variable "url" has been set.

Logo ALT text: Error: no local variable "logoalt" has been set.