PARSE XML IN PHP

2019-08-25 09:45发布

HI , all ..

I need to parse an DWF file using PHP, which looks like an xml file . example :

    <dwf:Feature id="BXV1D8mWfkGOqXbyoIxQ2g">
 <dwf:Properties id="hZBTdWkXKEuhGWAeTpMOUA">
  <dwf:Property name="NO" value="0" /> 
  <dwf:Property name="DESCRIPTION" value="Testing" /> 
  <dwf:Property name="DATE" value="06/25/09" /> 
  <dwf:Property name="BY" value="SJ" /> 
  <dwf:Property name="CHK" value="JF" /> 
  </dwf:Properties>

How to parse this.. I am new to PHP xml parsing ..

标签: php parsing
2条回答
我命由我不由天
2楼-- · 2019-08-25 09:59

You can use DOMDocument. To deal with namespaces (which you have) take a look at the methods that end in NS.

An alternative is SimpleXML. The SimpleXMLElement::children methods accepts a namespace or namespace prefix.

查看更多
唯我独甜
3楼-- · 2019-08-25 10:00

Use simplexml, like so: http://blog.sherifmansour.com/?p=302

Would be nice if you provided the xml prolog as well. The children method accepts a namespace prefix if you need to use that.

查看更多
登录 后发表回答