XmlSearch()

Uses an XPath language expression to search an XML document object.

XmlSearch( xml=xml, xpath=string );

Returns: object

Argument Description
xml
xml, required

XML document object

Alias: xmlObj, xmlDoc, node

xpath
string, required

XPath expression

Alias: path, xPathString

Examples

xml_stream = '
			<?xml version="1.0" encoding="UTF-8"?>
			<notes>
				<note>
					<to>Alice</to>
					<from>Bob</from>
					<heading>Reminder</heading>
					<body>Here is the message you requested.</body>
				</note>
				<note>
					<to>Bob</to>
					<from>Alice</from>
					<heading>Your request</heading>
					<body>I got your message; all is well.</body>
				</note>
			</notes>';
	<span class="nv">xml_document</span> <span class="o">=</span> <span class="nf">XmlParse</span><span class="p">(</span><span class="nv">xml_stream</span><span class="p">);</span>
	<span class="nf">dump</span><span class="p">(</span><span class="nf">XmlSearch</span><span class="p">(</span><span class="nv">xml_document</span><span class="p">,</span><span class="s2">&quot;/notes/note[last()]/body&quot;</span><span class="p">));</span> <span class="c">// I got your message; all is well.</span>

See also