<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I use SimpleXML pretty much exclusively for this stuff:<br>
<br>
$data='<this><br>
<that parm1="a" parm2="b" parm3="c">red</that><br>
<that parm1="e" parm2="f" parm3="d">blue</that><br>
</this>';<br>
<br>
$xml=simplexml_load_string($data);<br>
foreach ($xml->that as $item){<br>
print_r($item);<br>
echo "<hr>";<br>
}<br>
<br>
Returns:<br>
<br>
<span class="Apple-style-span" style="border-collapse: separate;
color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style:
normal; font-variant: normal; font-weight: normal; letter-spacing:
normal; line-height: normal; orphans: 2; text-indent: 0px;
text-transform: none; white-space: normal; widows: 2;
word-spacing: 0px; font-size: medium;">SimpleXMLElement Object (
[@attributes] => Array ( [parm1] => a [parm2] => b
[parm3] => c ) [0] => red )
<hr>SimpleXMLElement Object ( [@attributes] => Array ( [parm1]
=> e [parm2] => f [parm3] => d ) [0] => blue )<br>
<br>
Which is what it should. <br>
<br>
You can also use XPath to get at what you want:<br>
<br>
$xpath = $xml->xpath('/this/that');<br>
<br>
Which would return an array of each <that> item along with
the attributes.<br>
</span>
<pre class="moz-signature" cols="72">Jamie Holly
<a class="moz-txt-link-freetext" href="http://www.intoxination.net">http://www.intoxination.net</a>
<a class="moz-txt-link-freetext" href="http://www.hollyit.net">http://www.hollyit.net</a></pre>
<br>
On 3/24/2011 9:09 PM, <a class="moz-txt-link-abbreviated" href="mailto:jeff@ayendesigns.com">jeff@ayendesigns.com</a> wrote:
<blockquote cite="mid:4D8BEB3E.80800@ayendesigns.com" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
When all else fails, and #xml, ##php and #drupal-support come up
empty...ask the folks who actually code :)<br>
<br>
I have an xml structure that has<br>
<br>
<this><br>
<that parm1="a" parm2="b" parm3="c">red</that><br>
<that parm1="e" parm2="f" parm3="d">blue</that><br>
</this><br>
<br>
I've tried simplexml and a few third-party scripts, one that loads
the xml into an associative array rather than an object, and
nothing lets me get at 'red' or 'blue'. When I use dsm() on the
results, for example, in the case of the object with simplexml I
get only one 'that' and do not get its contents. When I use the
script that creates the array, I get both that's, and all their
parms as elements, but not the colors.<br>
<br>
I'm curious what else people are using.<br>
<br>
Jeff<br>
<div class="moz-signature">-- <br>
<meta http-equiv="CONTENT-TYPE" content="text/html;
charset=ISO-8859-1">
<title></title>
<meta name="GENERATOR" content="OpenOffice.org 3.2 (Linux)">
<meta name="CREATED" content="0;0">
<meta name="CHANGED" content="0;0">
<em>I am a non sequitur. Beware, the contents were packaged
where peanuts are processed.</em>
<p style="margin-bottom: 0in;"><img
src="cid:part1.00010706.07040302@earthlink.net"
name="ayenlogo" align="LEFT" border="0" height="54"
vspace="30" width="36"><font style="font-size: 8pt;"
size="1">Ayen
Designs </font><font face="Times New Roman, serif"><font
style="font-size: 8pt;" size="1"><br>
388 Bullsboro Drive #105 · Newnan, Georgia 30263</font></font>
<br>
<font face="Times New Roman, serif"><font style="font-size:
8pt;" size="1">404-271-9734<br>
Web:<a moz-do-not-send="true"
href="http://ayendesigns.com/">ayendesigns.com</a><br>
Blog: <a moz-do-not-send="true"
href="http://theaccidentalcoder.com/">theAccidentalCoder.com</a><br>
Drupal: <a moz-do-not-send="true"
href="http://drupal.org/user/367108">j. ayen green</a>
(367108)<br>
IRQ: j_ayen_green<br>
IM (Yahoo) baalwww (MSN) <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:baalwww@yahoo.com">baalwww@yahoo.com</a><br>
Skype: ayendesigns | Facebook: ayendesigns | Twitter:
@ayendesigns</font></font></p>
<p style="margin-bottom: 0in;"> <font face="Times New Roman,
serif"><font style="font-size: 8pt;" size="1"><br>
<br>
Ayen Designs is the computer services division of <img
src="cid:part2.03010400.02020700@earthlink.net"
name="acmelogo" align="ABSMIDDLE" border="0" height="31"
width="80"></font></font></p>
</div>
</blockquote>
</body>
</html>