Re: Problems with fscanf
| From: | Niel Archer | Date: | Tue, 26 Sep 2006 12:15:35 +0000 |
| Subject: | Re: Problems with fscanf | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-27178@lists.php.net to get a copy of this message | ||
Hi
First, if you're parsing XML files, I'd suggest using the XML modules to
do so.
I'm not sure what you're attempting. From the line:
<ARTIST>The Communards</ARTIST>
are you trying to retrieve all of it, or just "The Communards"? If the
latter then try a regex and not fscanf
This is a little loose on the tag matching but should do the job:
$pattern = '/<\w+>(.+)<\/\w+>/';
preg_match($pattern, $line, $matches);
returning the untagged data into $matches[1] and the tagged data into
$matches[0]
This assumes that you have only a single tagged entry per line.
Niel