Hey all. I'm still trying to learn RegEx, and in doing so, I've gotten pretty familiar with it, but just can't get what I want working.
Basically, I want to extract all that is within the normal opening and closing tags. So I have an XML document set up like:
<?xml version="1.0" encoding="UTF-8" />
<tag1>
<title>Some Title Text</title>
<group1>
<title>Some Title Text</title>
<name uri="someurl" other="optional">A name</name>
<name uri="someuri">A Name 2</name>
</group1>
</tag1>
Now, I don't want any titles, or version or crap like that. So I wrote out this simple code (PHP 4, so I can't use the PHP 5 xml calls):
<?php
$contents = file_get_contents('test.xml');
preg_match_all("/<name uri=\"[a-zA-Z0-9.]*\" ([a-zA-Z0-9.]*)?>([a-zA-Z0-9.])*<\/buddy>//i", $contents, $matches);
echo '<pre>';
var_dump($matches);
echo '</pre>';
?>
Now, that won't ouput anything except an empty array. BUT if I change the expression to:
"/>([a-zA-Z0-9.]*)</i"
it gives me an array of 99 items. not what I want because all the titles and such are included.
How can I define that I want only the elements that say <name ????>SomeName</name> to be seen? I know I can use the optional character (?) to say it could be there. Still struggling along.
~Brett