Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing php code to output the itemid in XML
    primarykey
    data
    text
    <p>I am trying to get my <a href="/questions/tagged/php" class="post-tag" title="show questions tagged 'php'" rel="tag">php</a> code to output the code in XML, however I'm unsure about how to get it to work properly. So far it outputs the code in php/html format.</p> <p>This is my XML: </p> <pre><code> &lt;bookcollection&gt; &lt;items&gt; &lt;item id="483"&gt; &lt;title&gt;Database systems management and design/&lt;/title&gt; &lt;isbn&gt;0877091153&lt;/isbn&gt; &lt;url&gt;http://library.hud.ac.uk/catlink/bib/483&lt;/url&gt; &lt;borrowedcount&gt;28&lt;/borrowedcount&gt; &lt;courses&gt; &lt;course&gt;CC140&lt;/course&gt; &lt;/courses&gt; &lt;/item&gt; &lt;/items&gt; &lt;/bookcollection&gt; </code></pre> <p>And the PHP:</p> <pre><code>&lt;?php $xmlassignDoc = new DOMDocument(); $xmlassignDoc-&gt;load("books.xml"); $books = $xmlassignDoc-&gt;getElementsByTagName("item"); foreach($books as $list) { $bookID = $list-&gt;getAttribute("id"); //HERE is where the GET function will be if ($bookID == '483') { $id = $list-&gt;getAttribute("id"); echo "&lt;b&gt;Book ID: &lt;/b&gt; $id &lt;br&gt;"; $title = $list-&gt;getElementsByTagName("title"); $title = $title-&gt;item(0)-&gt;nodeValue; echo "&lt;b&gt;Title: &lt;/b&gt; $title &lt;br&gt;"; $isbn = $list-&gt;getElementsByTagName("isbn"); $isbn = $isbn-&gt;item(0)-&gt;nodeValue; echo "&lt;b&gt;ISBN: &lt;/b&gt; $isbn &lt;br&gt;"; $borrowed = $list-&gt;getElementsByTagName("borrowedcount"); $borrowed = $borrowed-&gt;item(0)-&gt;nodeValue; echo "&lt;b&gt;Borrowed Count: &lt;/b&gt; $borrowed &lt;br&gt;"; echo "&lt;br&gt;"; } } ?&gt; </code></pre> <p>Any ideas would help me a lot.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload