XPath
HI all,
just look at following xml file.
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
<publication>
<date>12</date>
<month>1</month>
<year>2005</year>
</publication>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
<publication>
<date>12</date>
<month>2</month>
<year>2005</year>
</publication>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
<publication>
<date>12</date>
<month>3</month>
<year>2005</year>
</publication>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
<publication>
<date>12</date>
<month>4</month>
<year>2005</year>
</publication>
</book>
</bookstore>
Now look at following html file:
<html>
<body>
<script type="text/vbscript">
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("books.xml")
set nodes=xmlDoc.selectNodes("/bookstore/book/publication[month=3]/month | /bookstore/book/author")
for each x in nodes
document.write("<xmp>")
document.write(x.xml)
document.write("</xmp>")
next
</script>
</body>
<!-- | /bookstore/book/publication[month=3]/month
/bookstore/book/author
set nodes=xmlDoc.selectNodes("/bookstore/book/publication[month=3]/month | /bookstore/book/author")
-->
</html>
Now question:
Write XPath for finding "Author" given that "month" is "3"
|