This is a discussion on XML DOM within the PHP General forums, part of the PHP Programming Forums category; I have an XML document as a string $strXml, that looks a little like this: <recordset> <row&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have an XML document as a string $strXml, that looks a little like this:
<recordset> <row> <userid>1</userid> <username>Bob</username> <password>Rover</username> </row> <row> <userid>2</userid> <username>Fred</username> <password>Fido</username> </row> </recordset> What's the best way to grab a single value from this document? In the past (in VB), I have loaded the XML into a DOM Document, and used an XPath query to select the data I want, and then bung the output into a string. Any suggestions? Thanks Ian |
|
|||
|
Ian Williams wrote:
> I have an XML document as a string $strXml, that looks a little like this: > > <recordset> > <row> > <userid>1</userid> > <username>Bob</username> > <password>Rover</username> > </row> > <row> > <userid>2</userid> > <username>Fred</username> > <password>Fido</username> > </row> > </recordset> > > What's the best way to grab a single value from this document? In the past > (in > VB), I have loaded the XML into a DOM Document, and used an XPath query to > select the data I want, and then bung the output into a string. > > Any suggestions? You can do the same bunging in PHP if your php setup has domxml enabled. Or you can use the (faster, but batch-like) SAX parser. More information : http://www.php.net/xml -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com |