bonjour
je vous ecrit car je n'ay comprend plus rien, j'ai un fichier xml et j'aimerais generer un autre fichier xml à partir du premier avec une requête xpathmais ça ne m'affiche rien de bon.
je vous donne le fichier xml de départ
[xml]
<mondial>
<country car_code="SRB" area="77474" capital="city-Belgrade-SRB-SRB"
memberships="org-BSEC org-CE org-CEI org-EBRD org-FAO org-G-9 org-IAEA org-IBRD org-ICAO org-ICC org-ICRM org-IDA org-IFC org-IFRCS org-ILO org-IMF org-IMO org-Interpol org-IOC org-IOM org-ISO org-ITU org-OSCE org-PCA org-PFP org-UN org-UNCTAD org-UNESCO org-UNHCR org-UNIDO org-UPU org-WCL org-WFTU org-WHO org-WIPO org-WMO">
<name>Serbia</name>
<population>7379339</population>
<population_growth>-0.47</population_growth>
<infant_mortality>6.75</infant_mortality>
<gdp_total>52180</gdp_total>
<gdp_agri>12.3</gdp_agri>
<gdp_ind>24.2</gdp_ind>
<gdp_serv>63.5</gdp_serv>
<inflation>6.8</inflation>
<indep_date>2006-06-05</indep_date>
<government>parliamentary democracy</government>
<encompassed continent="europe" percentage="20"/>
<encompassed continent="asie" percentage="80"/>
<ethnicgroups percentage="82.9">Serb</ethnicgroups>
<ethnicgroups percentage="0.9">Montenegrin</ethnicgroups>
<ethnicgroups percentage="3.9">Hungarian</ethnicgroups>
<ethnicgroups percentage="1.4">Roma</ethnicgroups>
<ethnicgroups percentage="1.8">Bosniak</ethnicgroups>
<ethnicgroups percentage="1.1">Croat</ethnicgroups>
<religions percentage="85">Christian Orthodox</religions>
<religions percentage="3.2">Muslim</religions>
<religions percentage="5.5">Roman Catholic</religions>
<religions percentage="1.1">Protestant</religions>
<languages percentage="88.3">Serbian</languages>
<languages percentage="3.8">Hungarian</languages>
<languages percentage="1.8">Bosnian</languages>
<languages percentage="1.1">Roma</languages>
<border country="H" length="151"/>
<border country="RO" length="476"/>
<border country="BG" length="318"/>
<border country="MK" length="62"/>
<border country="HR" length="241"/>
<border country="BIH" length="302"/>
<border country="MNE" length="124"/>
<border country="KOS" length="352"/>
<city id="city-Belgrade-SRB-SRB" is_country_cap="yes"
country="SRB">
<name>moscou</name>
<longitude>20.4667</longitude>
<latitude>44.8</latitude>
<population year="87">1407073</population>
<located_at watertype="river" river="river-Donau"/>
<located_at watertype="river" river="river-Save"/>
</city>
</country>
</mondial>
[xml]
et je dois obtenir ceci
[xml]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE liste-pays SYSTEM "liste-pays.dtd">
<liste-pays>
<pays nom="Russia" capitale="Moscow" proportion-asie="80" proportion-autres="20"/>
</liste-pays>
[xml]
avec php
j'ai fait ce code
[php]
<?php
$dom_object = new DomDocument();
$dom_object->load("mondial.xml" );
$xpath = new DOMXPath($dom_object);
$arts = $xpath->query('mondial/country');
foreach ($arts as $art)
{//$nom = $art->getElementsByTagName('nom')->item(1)->nodeValue;
$art1 = $xpath->query('mondial/country/encompassed[@percentage<100]');
foreach ($art1 as $art1){$nom = $art->getElementsByTagName('nom')->item(1)->nodeValue;}}
echo $dom_object->saveXML();
?>
[php]
mais ça ne s'affiche pas sur la même ligne
merci