PARCER UN FICHIER XML EN PHP
boby87000
Messages postés
132
Statut
Membre
-
boby87000 Messages postés 132 Statut Membre -
boby87000 Messages postés 132 Statut Membre -
Bonjour,
je développe une appli et je vous une fonction qui me permet de parcer un fichier XML et m'affiche dans les contenus des différentes informations contenus dans les balises XML
exemple:
<entry method="GET" URL="http://prep.fr/prep/fra/css/StylesV9.3.0.css">
<pageref idref="page_0" />
<started>00:00:01.490</started>
<startedDateTime>2009-10-01T09:09:01.147</startedDateTime>
<time>0.084</time>
<sent>812</sent>
<received>19906</received> <result>200</result>
<overview>
<action name="Display URL" status="Completed">Normal browser lookup of URL http://prep.fr/prep/fra/css/StylesV9.3.0.css</action>
<action name="Started At" status="Completed">2009-Oct-01 09:09:01.147 (local time)</action>
<action name="HTTP Request" status="Completed">Unconditional request sent for http://prep..fr/prep/fra/css/StylesV9.3.0.css</action>
<action name="HTTP Response" status="Completed">Headers and content returned</action>
</overview>
<request>
<requestMethod>GET http://prep.fr/prep/fra/css/StylesV9.3.0.css HTTP/1.1</requestMethod>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="" domain="">2554268628.20992.0000</cookie>
<cookie name="itiOptions_2" path="" domain="">yourPreference1:false,yourPreference2:false,yourPreference3:false,yourPreference4:false,yourPreference5:true,uw:28/09/2009,wf:km,devise:1.0|EUR,vehiculeType1:0,vehiculeType2:0,vehiculeType3:0,qq:0,NA:1.3,indemnite:0,</cookie>
<cookie name="JSESSIONID" path="" domain="">ZGVKq-JoY6jqXNVUtpjVc8p</cookie>
</cookies>
<headers>
<header name="Accept">text/css,*/*;q=0.1</header>
<header name="Accept-Charset">ISO-8859-1,utf-8;q=0.7,*;q=0.7</header>
<header name="Accept-Encoding">gzip,deflate</header>
<header name="Accept-Language">fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3</header>
<header >0</header>
<header name="Host">prep.fr</header>
<header name="Keep-Alive">300</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Referer">http://prep.fr/prep/fra/dyn/controller/Itineraires</header>
<header name="User-Agent">Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3</header>
</headers>
</request>
<response>
<responseStatus>HTTP/1.0 200 OK</responseStatus>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="/" domain="prep.fr" expires="Thu, 01-Oct-2009 07:24:01 GMT">2554268628.20992.0000</cookie>
</cookies>
<headers>
<header name="Accept-Ranges">bytes</header>
<header name="Cache-Control">public</header>
<header name="Content-Encoding">gzip</header>
<header name="Content-Length">19242</header>
<header name="Content-Type">text/css</header>
<header name="Date">Thu, 01 Oct 2009 07:09:01 GMT</header>
<header name="Last-Modified">Thu, 24 Sep 2009 14:18:37 GMT</header>
<header name="P3P">CP="IDC DSP ADMa DEVa TAIi CONi OUR IND PHY ONL UNI COM NAV DEM STA"</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Server">IBM_HTTP_Server</header>
<header name="Set-Cookie">BIGipServerWEB-BETA=2554268628.20992.0000; expires=Thu, 01-Oct-2009 07:24:01 GMT; path=/</header>
<header name="Vary">Accept-Encoding,User-Agent</header>
<header name="prep">1.0 VM-PROXY01.prep-travel.com:8080 (squid/2.6.STABLE6)</header>
<header name="X-Cache">MISS from VM-PROXY01.prep-travel.com</header>
<header name="X-Cache-Lookup">MISS from VM-PROXY01.prep-travel.com:8080</header>
</headers>
<content>
<contentLength>109576</contentLength>
<compression>82.440</compression>
<encodingScheme>gzip</encodingScheme>
<mimeType>text/css</mimeType>
</content>
</response>
<cache>
<beforeRequest>
<URLInCache>false</URLInCache>
</beforeRequest>
<afterRequest>
<URLInCache>true</URLInCache>
<expires>2009-10-01T23:14:03</expires>
<lastModification>2009-09-24T14:18:37</lastModification>
<lastCacheUpdate>2009-10-01T07:09:01</lastCacheUpdate>
<lastAccess>2009-10-01T07:09:01</lastAccess>
<eTag></eTag>
<hitCount>1</hitCount>
</afterRequest>
</cache>
<timings>
<blocked started="0.000">0.003</blocked>
<send started="0.003">0.000</send>
<wait started="0.003">0.068</wait>
<receive started="0.072">0.011</receive>
<ttfb started="0.003">0.068</ttfb>
<network started="0.003">0.080</network>
</timings>
</entry>
<entry method="GET" URL="http://prep.fr/prep/fra/css/PrintV9.3.0.css">
<pageref idref="page_0" />
<started>00:00:01.494</started>
<startedDateTime>2009-10-01T09:09:01.151</startedDateTime>
<time>0.042</time>
<sent>811</sent>
<received>1050</received> <result>200</result>
<overview>
<action name="Display URL" status="Completed">Normal browser lookup of URL https://sites.google.com/site/physiquepclyceeturgot/
<action name="Started At" status="Completed">2009-Oct-01 09:09:01.151 (local time)</action>
<action name="HTTP Request" status="Completed">Unconditional request sent for http://prep.fr/prep/fra/css/PrintV9.3.0.css</action>
<action name="HTTP Response" status="Completed">Headers and content returned</action>
</overview>
<request>
<requestMethod>GET http://prep.fr/prep/fra/css/PrintV9.3.0.css HTTP/1.1</requestMethod>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="" domain="">2554268628.20992.0000</cookie>
<cookie name="itiOptions_2" path="" domain="">yourPreference1:false,yourPreference2:false,yourPreference3:false,yourPreference4:false,yourPreference5:true,uw:28/09/2009,wf:km,devise:1.0|EUR,vehiculeType1:0,vehiculeType2:0,vehiculeType3:0,qq:0,NA:1.3,indemnite:0,</cookie>
<cookie name="JSESSIONID" path="" domain="">ZGVKq-JoY6jqXNVUtpjVc8p</cookie>
</cookies>
<headers>
<header name="Accept">text/css,*/*;q=0.1</header>
<header name="Accept-Charset">ISO-8859-1,utf-8;q=0.7,*;q=0.7</header>
<header name="Accept-Encoding">gzip,deflate</header>
<header name="Accept-Language">fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3</header>
<header name="Cookie">itiOptions_2=yourPreference1:false,yourPreference2:false,yourPreference3:false,yourPreference4:false,yourPreference5:true,uw:28/09/2009,wf:km,devise:1.0|EUR,vehiculeType1:0,vehiculeType2:0,vehiculeType3:0,qq:0,NA:1.3,indemnite:0,; JSESSIONID=ZGVKq-JoY6jqXNVUtpjVc8p; BIGipServerWEB-BETA=2554268628.20992.0000</header>
<header name="Host">prep.fr</header>
<header name="Keep-Alive">300</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Referer">http://prep.fr/prep/fra/dyn/controller/Itineraires</header>
<header name="User-Agent">Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3</header>
</headers>
</request>
<response>
<responseStatus>HTTP/1.0 200 OK</responseStatus>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="/" domain="prep.fr" expires="Thu, 01-Oct-2009 07:24:01 GMT">2554268628.20992.0000</cookie>
</cookies>
<headers>
<header name="Accept-Ranges">bytes</header>
<header name="Cache-Control">public</header>
<header name="Content-Encoding">gzip</header>
<header name="Content-Length">388</header>
<header name="Content-Type">text/css</header>
<header name="Date">Thu, 01 Oct 2009 07:09:01 GMT</header>
<header name="Last-Modified">Thu, 24 Sep 2009 14:18:37 GMT</header>
<header name="P3P">CP="IDC DSP ADMa DEVa TAIi CONi OUR IND PHY ONL UNI COM NAV DEM STA"</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Server">IBM_HTTP_Server</header>
<header name="Set-Cookie">BIGipServerWEB-BETA=2554268628.20992.0000; expires=Thu, 01-Oct-2009 07:24:01 GMT; path=/</header>
<header name="Vary">Accept-Encoding,User-Agent</header>
<header name="prep">1.0 VM-PROXY01.prep-travel.com:8080 (squid/2.6.STABLE6)</header>
<header name="X-Cache">MISS from VM-PROXY01.prep-travel.com</header>
<header name="X-Cache-Lookup">MISS from VM-PROXY01.prep-travel.com:8080</header>
</headers>
<content>
<contentLength>658</contentLength>
<compression>41.033</compression>
<encodingScheme>gzip</encodingScheme>
<text><![CDATA[
padding: 0; background: none; color: #000;}
]]></text>
<mimeType>text/css</mimeType>
</content>
</response>
<cache>
<beforeRequest>
<URLInCache>false</URLInCache>
</beforeRequest>
<afterRequest>
<URLInCache>true</URLInCache>
<expires>2009-10-01T23:14:03</expires>
<lastModification>2009-09-24T14:18:37</lastModification>
<lastCacheUpdate>2009-10-01T07:09:01</lastCacheUpdate>
<lastAccess>2009-10-01T07:09:01</lastAccess>
<eTag></eTag>
<hitCount>1</hitCount>
</afterRequest>
</cache>
<timings>
<blocked started="0.000">0.003</blocked>
<send started="0.003">0.000</send>
<wait started="0.003">0.037</wait>
<receive started="0.041">0.000</receive>
<ttfb started="0.003">0.037</ttfb>
<network started="0.003">0.038</network>
</timings>
en somme je vous juste récupérer les champs entre les balises.
merci pour aide.
je développe une appli et je vous une fonction qui me permet de parcer un fichier XML et m'affiche dans les contenus des différentes informations contenus dans les balises XML
exemple:
<entry method="GET" URL="http://prep.fr/prep/fra/css/StylesV9.3.0.css">
<pageref idref="page_0" />
<started>00:00:01.490</started>
<startedDateTime>2009-10-01T09:09:01.147</startedDateTime>
<time>0.084</time>
<sent>812</sent>
<received>19906</received> <result>200</result>
<overview>
<action name="Display URL" status="Completed">Normal browser lookup of URL http://prep.fr/prep/fra/css/StylesV9.3.0.css</action>
<action name="Started At" status="Completed">2009-Oct-01 09:09:01.147 (local time)</action>
<action name="HTTP Request" status="Completed">Unconditional request sent for http://prep..fr/prep/fra/css/StylesV9.3.0.css</action>
<action name="HTTP Response" status="Completed">Headers and content returned</action>
</overview>
<request>
<requestMethod>GET http://prep.fr/prep/fra/css/StylesV9.3.0.css HTTP/1.1</requestMethod>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="" domain="">2554268628.20992.0000</cookie>
<cookie name="itiOptions_2" path="" domain="">yourPreference1:false,yourPreference2:false,yourPreference3:false,yourPreference4:false,yourPreference5:true,uw:28/09/2009,wf:km,devise:1.0|EUR,vehiculeType1:0,vehiculeType2:0,vehiculeType3:0,qq:0,NA:1.3,indemnite:0,</cookie>
<cookie name="JSESSIONID" path="" domain="">ZGVKq-JoY6jqXNVUtpjVc8p</cookie>
</cookies>
<headers>
<header name="Accept">text/css,*/*;q=0.1</header>
<header name="Accept-Charset">ISO-8859-1,utf-8;q=0.7,*;q=0.7</header>
<header name="Accept-Encoding">gzip,deflate</header>
<header name="Accept-Language">fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3</header>
<header >0</header>
<header name="Host">prep.fr</header>
<header name="Keep-Alive">300</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Referer">http://prep.fr/prep/fra/dyn/controller/Itineraires</header>
<header name="User-Agent">Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3</header>
</headers>
</request>
<response>
<responseStatus>HTTP/1.0 200 OK</responseStatus>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="/" domain="prep.fr" expires="Thu, 01-Oct-2009 07:24:01 GMT">2554268628.20992.0000</cookie>
</cookies>
<headers>
<header name="Accept-Ranges">bytes</header>
<header name="Cache-Control">public</header>
<header name="Content-Encoding">gzip</header>
<header name="Content-Length">19242</header>
<header name="Content-Type">text/css</header>
<header name="Date">Thu, 01 Oct 2009 07:09:01 GMT</header>
<header name="Last-Modified">Thu, 24 Sep 2009 14:18:37 GMT</header>
<header name="P3P">CP="IDC DSP ADMa DEVa TAIi CONi OUR IND PHY ONL UNI COM NAV DEM STA"</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Server">IBM_HTTP_Server</header>
<header name="Set-Cookie">BIGipServerWEB-BETA=2554268628.20992.0000; expires=Thu, 01-Oct-2009 07:24:01 GMT; path=/</header>
<header name="Vary">Accept-Encoding,User-Agent</header>
<header name="prep">1.0 VM-PROXY01.prep-travel.com:8080 (squid/2.6.STABLE6)</header>
<header name="X-Cache">MISS from VM-PROXY01.prep-travel.com</header>
<header name="X-Cache-Lookup">MISS from VM-PROXY01.prep-travel.com:8080</header>
</headers>
<content>
<contentLength>109576</contentLength>
<compression>82.440</compression>
<encodingScheme>gzip</encodingScheme>
<mimeType>text/css</mimeType>
</content>
</response>
<cache>
<beforeRequest>
<URLInCache>false</URLInCache>
</beforeRequest>
<afterRequest>
<URLInCache>true</URLInCache>
<expires>2009-10-01T23:14:03</expires>
<lastModification>2009-09-24T14:18:37</lastModification>
<lastCacheUpdate>2009-10-01T07:09:01</lastCacheUpdate>
<lastAccess>2009-10-01T07:09:01</lastAccess>
<eTag></eTag>
<hitCount>1</hitCount>
</afterRequest>
</cache>
<timings>
<blocked started="0.000">0.003</blocked>
<send started="0.003">0.000</send>
<wait started="0.003">0.068</wait>
<receive started="0.072">0.011</receive>
<ttfb started="0.003">0.068</ttfb>
<network started="0.003">0.080</network>
</timings>
</entry>
<entry method="GET" URL="http://prep.fr/prep/fra/css/PrintV9.3.0.css">
<pageref idref="page_0" />
<started>00:00:01.494</started>
<startedDateTime>2009-10-01T09:09:01.151</startedDateTime>
<time>0.042</time>
<sent>811</sent>
<received>1050</received> <result>200</result>
<overview>
<action name="Display URL" status="Completed">Normal browser lookup of URL https://sites.google.com/site/physiquepclyceeturgot/
<action name="Started At" status="Completed">2009-Oct-01 09:09:01.151 (local time)</action>
<action name="HTTP Request" status="Completed">Unconditional request sent for http://prep.fr/prep/fra/css/PrintV9.3.0.css</action>
<action name="HTTP Response" status="Completed">Headers and content returned</action>
</overview>
<request>
<requestMethod>GET http://prep.fr/prep/fra/css/PrintV9.3.0.css HTTP/1.1</requestMethod>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="" domain="">2554268628.20992.0000</cookie>
<cookie name="itiOptions_2" path="" domain="">yourPreference1:false,yourPreference2:false,yourPreference3:false,yourPreference4:false,yourPreference5:true,uw:28/09/2009,wf:km,devise:1.0|EUR,vehiculeType1:0,vehiculeType2:0,vehiculeType3:0,qq:0,NA:1.3,indemnite:0,</cookie>
<cookie name="JSESSIONID" path="" domain="">ZGVKq-JoY6jqXNVUtpjVc8p</cookie>
</cookies>
<headers>
<header name="Accept">text/css,*/*;q=0.1</header>
<header name="Accept-Charset">ISO-8859-1,utf-8;q=0.7,*;q=0.7</header>
<header name="Accept-Encoding">gzip,deflate</header>
<header name="Accept-Language">fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3</header>
<header name="Cookie">itiOptions_2=yourPreference1:false,yourPreference2:false,yourPreference3:false,yourPreference4:false,yourPreference5:true,uw:28/09/2009,wf:km,devise:1.0|EUR,vehiculeType1:0,vehiculeType2:0,vehiculeType3:0,qq:0,NA:1.3,indemnite:0,; JSESSIONID=ZGVKq-JoY6jqXNVUtpjVc8p; BIGipServerWEB-BETA=2554268628.20992.0000</header>
<header name="Host">prep.fr</header>
<header name="Keep-Alive">300</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Referer">http://prep.fr/prep/fra/dyn/controller/Itineraires</header>
<header name="User-Agent">Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3</header>
</headers>
</request>
<response>
<responseStatus>HTTP/1.0 200 OK</responseStatus>
<cookies>
<cookie name="BIGipServerWEB-BETA" path="/" domain="prep.fr" expires="Thu, 01-Oct-2009 07:24:01 GMT">2554268628.20992.0000</cookie>
</cookies>
<headers>
<header name="Accept-Ranges">bytes</header>
<header name="Cache-Control">public</header>
<header name="Content-Encoding">gzip</header>
<header name="Content-Length">388</header>
<header name="Content-Type">text/css</header>
<header name="Date">Thu, 01 Oct 2009 07:09:01 GMT</header>
<header name="Last-Modified">Thu, 24 Sep 2009 14:18:37 GMT</header>
<header name="P3P">CP="IDC DSP ADMa DEVa TAIi CONi OUR IND PHY ONL UNI COM NAV DEM STA"</header>
<header name="Proxy-Connection">keep-alive</header>
<header name="Server">IBM_HTTP_Server</header>
<header name="Set-Cookie">BIGipServerWEB-BETA=2554268628.20992.0000; expires=Thu, 01-Oct-2009 07:24:01 GMT; path=/</header>
<header name="Vary">Accept-Encoding,User-Agent</header>
<header name="prep">1.0 VM-PROXY01.prep-travel.com:8080 (squid/2.6.STABLE6)</header>
<header name="X-Cache">MISS from VM-PROXY01.prep-travel.com</header>
<header name="X-Cache-Lookup">MISS from VM-PROXY01.prep-travel.com:8080</header>
</headers>
<content>
<contentLength>658</contentLength>
<compression>41.033</compression>
<encodingScheme>gzip</encodingScheme>
<text><![CDATA[
padding: 0; background: none; color: #000;}
]]></text>
<mimeType>text/css</mimeType>
</content>
</response>
<cache>
<beforeRequest>
<URLInCache>false</URLInCache>
</beforeRequest>
<afterRequest>
<URLInCache>true</URLInCache>
<expires>2009-10-01T23:14:03</expires>
<lastModification>2009-09-24T14:18:37</lastModification>
<lastCacheUpdate>2009-10-01T07:09:01</lastCacheUpdate>
<lastAccess>2009-10-01T07:09:01</lastAccess>
<eTag></eTag>
<hitCount>1</hitCount>
</afterRequest>
</cache>
<timings>
<blocked started="0.000">0.003</blocked>
<send started="0.003">0.000</send>
<wait started="0.003">0.037</wait>
<receive started="0.041">0.000</receive>
<ttfb started="0.003">0.037</ttfb>
<network started="0.003">0.038</network>
</timings>
en somme je vous juste récupérer les champs entre les balises.
merci pour aide.
A voir également:
- PARCER UN FICHIER XML EN PHP
- Fichier bin - Guide
- Comment ouvrir un fichier epub ? - Guide
- Comment réduire la taille d'un fichier - Guide
- Fichier rar - Guide
- Fichier .dat - Guide