[phpXML] Basic question about xpath.class.php use
Brought to you by:
bs_php,
nigelswinson
From: <lu...@sa...> - 2001-10-08 17:48:09
|
Hello, I've some problems with xpath.class.php use and the new system The following piece of code works perfectly with xml.php 1N4 but no more with xpath.class.php xpath.class.php version is at : http://www.interpasnet.com/xmlprocess.xpath.php?screen=cachecache§ion=cachecache&file=cachecache.xml&id=1 xml.php 1N4 version is at http://www.interpasnet.com/xmlprocess.php?screen=cachecache§ion=cachecache&file=cachecache.xml&id=1 Error is : phpXML error: While parsing an XPath expression there was an error in the predicate "1", because it was the null string. If you wish to seach for the empty string, you must use ''. What am I supposed to change ? Luc ================== BEGIN ============================ $xml_file = 'xml_files/'.$section.'/'.$file; if ($file =="cachecache.xml"){ $xml_data = $tpl->fetch('../'.$xml_file); $xml = new XPath(); $xml->load_string ($xml_data); } else { $xml = new XPath($xml_file); } $array_article_entete= array(); $array_article_corps= array(); $array_article_listing = array(); $t = array(); $articles = $xml->evaluate('/article'); foreach ( $articles as $article ) { $category = $xml->get_content($article.'/category[1]'); $version = $xml->get_content($article.'/version[1]'); $source_url = $xml->get_content($article.'/source[1]/url[1]'); $source_livre = $xml->get_content($article.'/source[1]/livre[1]'); $source_commentaire = $xml->get_content($article.'/source[1]/commentaire[1]'); $copyright = $xml->get_content($article.'/copyright[1]'); $author_name = $xml->get_content($article.'/author[1]/name[1]'); $author_adress_name = $xml->get_content($article.'/author[1]/adress[1]/name[1]'); $author_adress_phone= $xml->get_content($article.'/author[1]/adress[1]/phone[1]'); $author_email = $xml->get_content($article.'/author[1]/email[1]'); $title = $xml->get_content($article.'/title[1]'); $abstract = $xml->get_content($article.'/abstract[1]'); array_push ($array_article_entete, array( 'category' =>$category, 'version' =>$version, 'source_url' =>$source_url, 'source_livre' =>$source_livre, 'source_commentaire'=>$source_commentaire, 'copyright' =>$copyright, 'author_name' =>$author_name, 'author_adress_name' =>$author_adress_name, 'author_adress_phone' =>$author_adress_phone, 'author_email' =>$author_email, 'article_title' =>$title, 'abstract' =>$abstract ) ); } if ( !empty($id) ) { $blocs = $xml->evaluate('//paragraph[@id='.$id.']'); } else { $blocs = $xml->evaluate('/article/paragraph'); } foreach ( $blocs as $bloc ) { $t = $xml->get_attributes( $bloc); $id = $t['id']; $title = $xml->get_content($bloc.'/title[1]'); $chapo = $xml->get_content($bloc.'/chapo[1]'); $text = $xml->get_content($bloc.'/text[1]'); array_push($array_article_corps, array('paragraph_id'=>$id, 'paragraph_title'=>$title, 'paragraph_chapo'=>$chapo, 'paragraph_text'=>$text ) ); } $blocs = $xml->evaluate('/article/paragraph'); foreach ( $blocs as $bloc ) { $t = $xml->get_attributes( $bloc); $id = $t['id']; $title = $xml->get_content($bloc.'/title[1]'); array_push($array_article_listing, array('paragraph_id'=>$id, 'paragraph_title'=>$title ) ); } ====================== END =========================== -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |