Page 1 of 1
xml stuff
Posted: Thu Feb 16, 2006 4:47 pm
by shiznatix
Well ok its not really XML its just some my own tags in a txt document. Here is what I have
Code: Select all
<title>title</title>
<short>short</short>
<long>whole</long>
I need to get 'title' into 1 variable, 'short' into another, and 'whole' into a third. I searched for some html regex here but I did not understand any of it. Some help please.....
Posted: Thu Feb 16, 2006 4:49 pm
by hawleyjr
Do a search for xml to array there are a couple good classes out there to help

Posted: Thu Feb 16, 2006 5:01 pm
by josh
http://us3.php.net/simplexml
This works with valid XML documents
Posted: Fri Feb 17, 2006 6:13 pm
by raghavan20
untested...but probably should work...
Code: Select all
$input =<<<EOT
<title>title</title>
<short>short</short>
<long>whole</long>
EOT;
preg_matches("#<title>(.*?)</title>#i", $inputString, $matches);
$titleString = implode("", $matches[1]);
preg_matches("#<short>(.*?)</short>#i", $inputString, $matches);
$shortString = implode("", $matches[1]);
preg_matches("#<long>(.*?)</long>#i", $inputString, $matches);
$longString = implode("", $matches[1]);