Note that there are some explanatory texts on larger screens.

plurals
  1. POGrabbing a Specific Part of the Previous / Next Nodes
    primarykey
    data
    text
    <p>I am looping through a XML file with SimpleXML and trying to pull a specific piece of data (specifically, the <strong><em>series->displayname</em></strong> attribute) from the Previous and Next nodes each time.</p> <p><strong>Here is a sample of the XML structure:</strong></p> <pre><code>&lt;comic&gt; &lt;id&gt;117&lt;/id&gt; &lt;index&gt;1&lt;/index&gt; &lt;mainsection&gt; &lt;pagecount&gt;33&lt;/pagecount&gt; &lt;series&gt; &lt;displayname&gt;Amazing Story&lt;/displayname&gt; &lt;sortname&gt;Amazing Story&lt;/sortname&gt; &lt;/series&gt; &lt;/mainsection&gt; &lt;/comic&gt; &lt;comic&gt; &lt;id&gt;102&lt;/id&gt; &lt;index&gt;1&lt;/index&gt; &lt;mainsection&gt; &lt;pagecount&gt;33&lt;/pagecount&gt; &lt;series&gt; &lt;displayname&gt;Fantastic Tale&lt;/displayname&gt; &lt;sortname&gt;Fantastic Tale&lt;/sortname&gt; &lt;/series&gt; &lt;/mainsection&gt; &lt;/comic&gt; &lt;comic&gt; &lt;id&gt;85&lt;/id&gt; &lt;index&gt;1&lt;/index&gt; &lt;mainsection&gt; &lt;pagecount&gt;33&lt;/pagecount&gt; &lt;series&gt; &lt;displayname&gt;The Great Tale&lt;/displayname&gt; &lt;sortname&gt;The Great Tale&lt;/sortname&gt; &lt;/series&gt; &lt;/mainsection&gt; &lt;/comic&gt; </code></pre> <p><strong>And here is a sample of the structure I am using in the loop:</strong></p> <pre><code>$prevIssue = $comic-&gt;xpath('preceding-sibling::*')-&gt;mainsection-&gt;series-&gt;displayname; $nextIssue = $comic-&gt;xpath('following-sibling::*')-&gt;mainsection-&gt;series-&gt;displayname; echo ' &lt;li class="issue" id="' . $seriesCat . '"&gt; &lt;h3&gt;' . $comicSeriresName . '&lt;/h3&gt; &lt;div id="details"&gt; &lt;span id="publisher"&gt;' . $comicPublisher . '&lt;/span&gt;&lt;br&gt; The last series was called "' . $prevIssue . '&lt;br&gt; The next series is called "' . $nextIssue . '&lt;br&gt; &lt;/div&gt; &lt;/li&gt;'; </code></pre> <p>However, the 'nextIssue' and 'prevIssue' variables are not working. They are returning a blank result. What am I doing wrong?</p> <p>Any guidance is greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    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