IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
<html><head><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"><title>Using XPath to Retrieve Element Content</title><metaname="generator"content="DocBook XSL Stylesheets V1.61.2"><linkrel="home"href="index.html"title="Libxml Tutorial"><linkrel="up"href="index.html"title="Libxml Tutorial"><linkrel="previous"href="ar01s04.html"title="Retrieving Element Content"><linkrel="next"href="ar01s06.html"title="Writing element content"></head><bodybgcolor="white"text="black"link="#0000FF"vlink="#840084"alink="#0000FF"><divclass="navheader"><tablewidth="100%"summary="Navigation header"><tr><thcolspan="3"align="center">Using XPath to Retrieve Element Content</th></tr><tr><tdwidth="20%"align="left"><aaccesskey="p"href="ar01s04.html">Prev</a><EFBFBD></td><thwidth="60%"align="center"><EFBFBD></th><tdwidth="20%"align="right"><EFBFBD><aaccesskey="n"href="ar01s06.html">Next</a></td></tr></table><hr></div><divclass="sect1"lang="en"><divclass="titlepage"><div><div><h2class="title"style="clear: both"><aname="xmltutorialxpath"></a>Using XPath to Retrieve Element Content</h2></div></div><div></div></div><p>In addition to walking the document tree to find an element,
</p><divclass="note"style="margin-left: 0.5in; margin-right: 0.5in;"><tableborder="0"summary="Note"><tr><tdrowspan="2"align="center"valign="top"width="25"><imgalt="[Note]"src="images/note.png"></td><thalign="left">Note</th></tr><tr><tdcolspan="2"align="left"valign="top"><p>A full discussion of <spanclass="application">XPath</span> is beyond
the scope of this document. For details on its use, see the <ahref="http://www.w3.org/TR/xpath"target="_top">XPath specification</a>.</p></td></tr></table></div><p>
</p><divclass="calloutlist"><tableborder="0"summary="Callout list"><tr><tdwidth="5%"valign="top"align="left"><ahref="#cocontext"><imgsrc="images/callouts/1.png"alt="1"border="0"></a></td><tdvalign="top"align="left"><p>First we declare our variables.</p></td></tr><tr><tdwidth="5%"valign="top"align="left"><ahref="#cocreatecontext"><imgsrc="images/callouts/2.png"alt="2"border="0"></a></td><tdvalign="top"align="left"><p>Initialize the <ttclass="varname">context</tt> variable.</p></td></tr><tr><tdwidth="5%"valign="top"align="left"><ahref="#corunxpath"><imgsrc="images/callouts/3.png"alt="3"border="0"></a></td><tdvalign="top"align="left"><p>Apply the <spanclass="application">XPath</span> expression.</p></td></tr><tr><tdwidth="5%"valign="top"align="left"><ahref="#cocheckxpathresult"><imgsrc="images/callouts/4.png"alt="4"border="0"></a></td><tdvalign="top"align="left"><p>Check the result and free the memory allocated to
<ttclass="varname">result</tt> if no result is found.</p></td></tr></table></div><p>
</p><divclass="calloutlist"><tableborder="0"summary="Callout list"><tr><tdwidth="5%"valign="top"align="left"><ahref="#conodesetcounter"><imgsrc="images/callouts/1.png"alt="1"border="0"></a></td><tdvalign="top"align="left"><p>The value of <ttclass="varname">nodeset->Nr</tt> holds the number of
elements in the node set. Here we use it to iterate through the array.</p></td></tr><tr><tdwidth="5%"valign="top"align="left"><ahref="#coprintkeywords"><imgsrc="images/callouts/2.png"alt="2"border="0"></a></td><tdvalign="top"align="left"><p>Here we print the contents of each of the nodes returned.
</p><divclass="note"style="margin-left: 0.5in; margin-right: 0.5in;"><tableborder="0"summary="Note"><tr><tdrowspan="2"align="center"valign="top"width="25"><imgalt="[Note]"src="images/note.png"></td><thalign="left">Note</th></tr><tr><tdcolspan="2"align="left"valign="top"><p>Note that we are printing the child node of the node that is
</p></div><divclass="navfooter"><hr><tablewidth="100%"summary="Navigation footer"><tr><tdwidth="40%"align="left"><aaccesskey="p"href="ar01s04.html">Prev</a><EFBFBD></td><tdwidth="20%"align="center"><aaccesskey="u"href="index.html">Up</a></td><tdwidth="40%"align="right"><EFBFBD><aaccesskey="n"href="ar01s06.html">Next</a></td></tr><tr><tdwidth="40%"align="left"valign="top">Retrieving Element Content<6E></td><tdwidth="20%"align="center"><aaccesskey="h"href="index.html">Home</a></td><tdwidth="40%"align="right"valign="top"><EFBFBD>Writing element content</td></tr></table></div></body></html>