Note that there are some explanatory texts on larger screens.

plurals
  1. POSort/Group XML data with PHP?
    primarykey
    data
    text
    <p>I'm trying to make a page using data from the discogs.com (XML)-API. i've been parsing it with simpleXML and it's working pretty well but there is some things i'm not sure how to do.</p> <p>Here is part of the XML:</p> <pre><code>&lt;releases&gt; &lt;release id="1468764" status="Accepted" type="Main"&gt; &lt;title&gt;Versions&lt;/title&gt; &lt;format&gt;12", EP&lt;/format&gt; &lt;label&gt;Not On Label&lt;/label&gt; &lt;year&gt;1999&lt;/year&gt; &lt;/release&gt; &lt;release id="72246" status="Accepted" type="Main"&gt; &lt;title&gt;The M.O.F Blend&lt;/title&gt; &lt;format&gt;LP&lt;/format&gt; &lt;label&gt;Blenda Records&lt;/label&gt; &lt;year&gt;2002&lt;/year&gt; &lt;/release&gt; &lt;release id="890064" status="Accepted" type="Main"&gt; &lt;title&gt;The M.O.F Blend&lt;/title&gt; &lt;format&gt;CD&lt;/format&gt; &lt;label&gt;Blenda Records&lt;/label&gt; &lt;year&gt;2002&lt;/year&gt; &lt;/release&gt; &lt;release id="1563561" status="Accepted" type="TrackAppearance"&gt; &lt;title&gt;Ännu En Gång Vol. 3&lt;/title&gt; &lt;trackinfo&gt;Backtrack&lt;/trackinfo&gt; &lt;format&gt;Cass, Comp, Mix&lt;/format&gt; &lt;label&gt;Hemmalaget&lt;/label&gt; &lt;year&gt;2001&lt;/year&gt; &lt;/release&gt; &lt;/releases&gt; </code></pre> <p>What i want to achieve is something similair to how discogs presents the releases: <a href="http://www.discogs.com/artist/Mics+Of+Fury" rel="nofollow noreferrer">http://www.discogs.com/artist/Mics+Of+Fury</a> where diferent versions of the same release are sorted together. (see. The M.O.F Blend in my link) This is done on discogs with having a master release that features the other releases. unfortunately this information isn't present in the API data, so i want to do the same thing by grouping the <code>&lt;release&gt;</code>-nodes with the same <code>&lt;title&gt;</code>-tags, or add a flag to the <code>&lt;releases&gt;</code> that don't have a unique <code>&lt;title&gt;</code>? any good ideas on the best way of doing this?</p> <p>i also like to know if it's possible to count the <code>&lt;release&gt;</code>-nodes (child of releases) that have the same type-attribute? like in this example count the releases with the type "Main"?</p> <p>maybe it's better to do this things with XMLReader or XPath?</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.
    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