|
|
Line 191: |
Line 191: |
|
$result[] = $node; |
|
$result[] = $node; |
|
} |
|
} |
|
|
|
⚫ |
|
|
⚫ |
#Example taken from the REXML tutorial (http://www.germane-software.com/software/rexml/docs/tutorial.html) |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
#create the REXML Document from the string (%q is Ruby's multiline string, everything between the two @-characters is the string) |
|
⚫ |
|
|
⚫ |
%q@<inventory title="OmniCorp Store #45x10^3"> |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
# The invisibility cream is the first <item> |
|
⚫ |
invisibility = XPath.first( doc, "//item" ) |
|
⚫ |
# Prints out all of the prices |
|
⚫ |
XPath.each( doc, "//price") { |element| puts element.text } |
|
⚫ |
# Gets an array of all of the "name" elements in the document. |
|
⚫ |
names = XPath.match( doc, "//name" ) |
|
|
|
|
|
|
=={{header|Python}}== |
|
=={{header|Python}}== |
Line 231: |
Line 213: |
|
namesArray = xmldoc.getElementsByTagName("name") |
|
namesArray = xmldoc.getElementsByTagName("name") |
|
</pre> |
|
</pre> |
|
|
|
|
⚫ |
|
|
⚫ |
#Example taken from the REXML tutorial (http://www.germane-software.com/software/rexml/docs/tutorial.html) |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
#create the REXML Document from the string (%q is Ruby's multiline string, everything between the two @-characters is the string) |
|
⚫ |
|
|
⚫ |
%q@<inventory title="OmniCorp Store #45x10^3"> |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
# The invisibility cream is the first <item> |
|
⚫ |
invisibility = XPath.first( doc, "//item" ) |
|
⚫ |
# Prints out all of the prices |
|
⚫ |
XPath.each( doc, "//price") { |element| puts element.text } |
|
⚫ |
# Gets an array of all of the "name" elements in the document. |
|
⚫ |
names = XPath.match( doc, "//name" ) |
|
|
|
|
|
=={{header|XSLT}}== |
|
=={{header|XSLT}}== |