Perl Cd Bookshelf [Electronic resources]

Mark V. Scardina, Ben ChangandJinyu Wang

نسخه متنی -صفحه : 218/ 162
نمايش فراداده

Running the cppextract Application

Cppextract implements both application types described in the beginning of the chapter through different sets of command-line parameters: Since cppextract only depends upon the C run-time library and the oraxml10 library, it can be run with no explicit setup from the command line.

Running cppextract in Extraction Mode

Using the booklist.xml document you can extract a variety of data by passing in the appropriate XPath expression as the XPath parameter. The following are example command lines and their resulting extractions:

cppextract booklist.xml //book/title/text()
Node Value : The Adventures of Don Quixote
Node Value : The Iliad
booklist.xml number(//book[2]/price/text())
Numeric Value : 5
cppextract booklist.xml string(//book[2]/@*)
String Value : 5354

Running cppextract in Splitter Mode

In order to split an XML document with repeating subtrees, you can pass in the XPath expression that points to the element at the root of the subtree as the XPath parameter. Using these specific parameters will return the following XML documents:

cppextract booklist.xml "/bookcatalog/book"
<?xml version="1.0" encoding="UTF-8"?>
<book ISBN = "7564">
<title>The Adventures of Don Quixote</title>
<author_lastname>Cervantes</author_lastname>
<publisher>Oracle Press</publisher>
<year>2000</year>
<price>50.00</price>
</book>
<?xml version="1.0" encoding="UTF-8"?>
<book ISBN= "5354">
<title>The Iliad</title>
<author_lastname>Homer</author_lastname>
<publisher>Oracle Press</publisher>
<year>1000</year>
<price>5.00</price>
</book>