You are here: XML Parser « PHP Programming Language « IT news, forums, messages
XML Parser

Posted by Richard Price on 01/04/08 11:49

I am updating a xml parser developed by a third party. The xml below is
parsed by the system using the code that follows:

<Company>
- <section id="officers">
- <section id="secretary">
<section id="stakeholder id">15728499</section>
<section id="name">FRED BLOGGS</section>
</section>
- <section id="director" type="current">
<section id="stakeholder id">15728498</section>
<section id="name">JOHN SMITH</section>
</section>
</section>
- <section id="company identification">
<section id="name">ABC LIMITED</section>

$extract = parseXMLForLtd($xml, $type);
function parseXMLForLtd($xml="", $type) {
preg_match_all( "/\<section(.*?)\<\/section\>/s", $xml, $reportData);
$reportData[0] = preg_replace('/\n/i','',$reportData[0]);
$result = $reportData[0];
for($i=0; $i<count($result);$i++) {
$item = trim(stripslashes($result[$i]));

if(eregi('<section id="name">',$item) && eregi('<section id="company
identification">',$item)) {
$extract[name] = preg_replace('/([<][\/a-zA-Z0-9 ="-]+[>])/i', '',
$item);

However when I try to parse a the other field called "name" using:

else if(eregi('<section id="name">',$item) && eregi('<section
id="secretary">',$item)) {
$extract[secretary] = preg_replace('/([<][\/a-zA-Z0-9 ="-]+[>])/i',
'', $item);

It does not work. Could anyone please advise how I can extract "Fred
Bloggs"?

Thanks In Advance

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация