Xpathsapplycatalog catalogplantcommon xmlvalue

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t in an XML file •  Uses the hierarchy of a well- formed XML document to specify the desired chunks to extract •  Syntax is similar to but more powerful than the way files are located in a hierarchy of directories in a computer file system CATALOG PLANT COMMO BOTANI N CAL Bloodr oot Sangu ... ZONE 4 PLANT LIGHT Mostly Shady PRICE $2.44 AVAILABI LITY 03159 9 COMMO BOTANI N CAL Cardin al Flowe r Labeli a.. ZONE 2 LIGHT Shade PRICE $3.02 AVAILABI LITY 02229 9 <PLANT> <COMMON>Bloodroot </COMMON> <BOTANICAL>Sanguinaria canadensis </BOTANICAL> <ZONE>4</ZONE> <LIGHT>Mostly Shady </LIGHT> <PRICE>$2.44</PRICE> <AVAILABILITY>031599 </AVAILABILITY> </PLANT> /CATALOG/PLANT/COMMON CATALOG PLANT COMMO BOTANI N CAL Bloodr oot Sangu ... ZONE 4 PLANT LIGHT Mostly Shady PRICE $2.44 AVAILABI LITY 03159 9 COMMO BOTANI N CAL Cardin al Flowe r Labeli a.. ZONE 2 LIGHT Shade PRICE $3.02 AVAILABI LITY 02229 9 Example > common = ! xpathSApply(catalog, ! "/CATALOG/PLANT/COMMON", xmlValue)! ! > head(common)! [1] "Bloodroot” "Columbine” "Marsh Marigold" [4] "Cowslip" "Dutchman's-Breeches” "Ginger, Wild" ! ! Example > xpX = ! paste("/CATALOG/PLANT/", varNames, sep="")! > xpx[1]! [1] "/CATALOG/PLANT/COMMON"! > res = ! sapply(xpx,function(var) ! xpathSApply(catalog, var, xmlValue))! > res[1:2, 1:3]! [1,] "Bloodroot" "Sanguinaria canadensis" "4" [2,] "Columbine" "Aquilegia canadensis" "3" ! <Envelope> <subject>Reference rates</subject> <Sender> <name>European Central Bank</name> </Sender> <Cube> <Cube 8me="2008- 04- 21"> <Cube currency="USD" rate="1.5898"/> <Cube currency="JPY" rate="164.43"/> <Cube currency="BGN" rate="1.9558"/> <Cube currency="CZK" rate="25.091"/> </Cube> <Cube 8me="2008- 04- 17"> <Cube currency=&q...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online