I am new in XMLReader, and I think is kind of hard to find tutorials/code or something advanced to get examples.
My question is how can I transform the code I have now, so if I search (through a form) the term jQuery will give me the opportunity to output the value of <info></info>
(and later other elements) in every <name></name>
that is found in ?
This is the code that output the names of the books.
<?php
$reader = new XMLReader();
$reader->open("books.xml");
while ($reader->read()) {
switch ($reader->nodeType) {
case (XMLREADER::ELEMENT):
if ($reader->localName == "name") {
$reader->read();
echo $reader->value;
break;
}}}
?>
the xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<library>
<book isbn="781">
<name>SCJP 1.5</name>
<info>Sun Certified Java Programmer book</info>
</book>
<book isbn="194">
<name>jQuery is Awesome!</name>
<info>jQuery Reference Book</info>
</book>
<book isbn="199">
<name>jQuery 101</name>
<info>All you need to know about jQuery</info>
</book>
</library>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…