Q:

How to extract tags from XML

I have a simple XML extraction issue that should be solvable with straight PHP and not require any libraries.
All I need to do is extract the values of one tag. For example, given the string of XML:
<ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ....>
 <Result>Foo</Result>
 <Result>Bar</Result>
</ResultSet>

I just need to put Foo and Bar in an array. What is the easiest way to do this?
Thanks!

A:

There's simpleXML in PHP 5 that should get you there quickly.
Check out the basic examples page.

A:

$xml = '<ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Result>Foo</Result><Result>Bar</Result></ResultSet>';
$obj = new SimpleXMLElement($xml);
$result_array = array();
foreach ($obj->Result as $value) {
  $result_array[] = (string)$value;
}

