xml parsing with php

Soldato
Joined
24 Nov 2002
Posts
16,378
Location
38.744281°N 104.846806°W
I am using the following to quickly parse some xml, however, there is more than one author.... and I'm not sure how to fix this.

xml:
Code:
  <Item Name="Author" Type="String">Barrett AJ</Item> 
  <Item Name="Author" Type="String">Rawlings ND</Item>

php:
Code:
$data = implode("", file($url)); 
preg_match_all ("/<DocSum>([^`]*?)<\/DocSum>/", $data, $matches);
foreach ($matches[0] as $match) {
preg_match ("/<Item Name=\"Author\" Type=\"String\">([^`]*?)<\/Item>/", $match, $authors);
	  }
$authors = implode(", ", $authors);
echo "authors: " . $authors;

output:
Code:
authors: Barrett AJ, Barrett AJ
 
Last edited:
Back
Top Bottom