Note that there are some explanatory texts on larger screens.

plurals
  1. POSimpleXML Reading Key/Value Pairs
    primarykey
    data
    text
    <p>I'm sure something like this will have come up before, but I'm struggling to find what I'm looking for on here at all. I've read previous answers here lots of times, but never asked or answered myself before!</p> <p>I'm using SimpleXML to read a response to an Amazon SimpleDB query, and the result is in the form;</p> <pre><code>&lt;Item&gt; &lt;Name&gt;Item 1&lt;/Name&gt; &lt;Attribute&gt; &lt;Name&gt;Title&lt;/Name&gt; &lt;Value&gt;Item 1 Title&lt;/Value&gt; &lt;/Attribute&gt; &lt;Attribute&gt; &lt;Name&gt;URL&lt;/Name&gt; &lt;Value&gt;Item 1 URL&lt;/Value&gt; &lt;/Attribute&gt; &lt;Attribute&gt; &lt;Name&gt;Description&lt;/Name&gt; &lt;Value&gt;Item 1 Description&lt;/Value&gt; &lt;/Attribute&gt; &lt;Attribute&gt; &lt;Name&gt;Site&lt;/Name&gt; &lt;Value&gt;Item 1 Site&lt;/Value&gt; &lt;/Attribute&gt; &lt;/Item&gt; &lt;Item&gt; &lt;Name&gt;Item 2&lt;/Name&gt; &lt;Attribute&gt; &lt;Name&gt;Title&lt;/Name&gt; &lt;Value&gt;Item 2 Title&lt;/Value&gt; &lt;/Attribute&gt; &lt;Attribute&gt; &lt;Name&gt;URL&lt;/Name&gt; &lt;Value&gt;Item 2 URL&lt;/Value&gt; &lt;/Attribute&gt; &lt;Attribute&gt; &lt;Name&gt;Description&lt;/Name&gt; &lt;Value&gt;Item 2 Description&lt;/Value&gt; &lt;/Attribute&gt; &lt;Attribute&gt; &lt;Name&gt;Site&lt;/Name&gt; &lt;Value&gt;Item 2 Site&lt;/Value&gt; &lt;/Attribute&gt; &lt;/Item&gt; </code></pre> <p>I've got no problem reading the 'Name' at the top of the item, using foreach() in PHP to list all of them, and I have managed to do the same to create a list of 'Key/Value' pairs to cycle through listing.</p> <p>I can't really figure out how to select, for example, a specific value of description, to place it where I want in a page.</p> <p>Selecting the Item->Attribute gives an array in the form;</p> <pre><code>[Name] -&gt; Title [Value] -&gt; Item 1 Title </code></pre> <p>And this is where I'm a bit stuck. Still within my existing foreach() cycling through the items, I want an array of the 'Attributes', so I can select, for example;</p> <pre><code>[Title] -&gt; Item 1 Title [URL] -&gt; Item 1 URL </code></pre> <p>And so on.</p> <p>I'm fine selecting the items and echoing their name, bit that's really as far as I get.</p> <p>Since this is such a newbie question, I'm sure it's been asked or answered before, I can't see an answer anywhere else, so if anyone can point me to one, I'd be very grateful!</p> <p>Thanks in Advance</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.
    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