tags:

views:

36

answers:

2

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 ..

+1  A: 

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.

meder
Thanks meder, i have used simplexml but the format here is different its not like <title>My Title</title> its like <title value="sds" /> so how do I get value of this sds ?
PHPNewuser
+1  A: 

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.

Artefacto
Thanks Artefacto, Any examples plz
PHPNewuser
@ravi See the manual, there are examples there (the linked pages include even a link that says "examples").
Artefacto
Thanks I got it :)
PHPNewuser