Re: CDATA
Brought to you by:
bs_php,
nigelswinson
|
From: Peter R. <php...@pe...> - 2004-01-21 19:52:04
|
On Wednesday 21 Jan 2004 17:54, Gabriel Thielsch wrote:
> Hello,
>
> I just can't figure out, how to get CDATA out of an element.
> My xml file:
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <Buyer>
> <User>
> <AboutMe>0</AboutMe>
> <AllowPaymentEdit>1</AllowPaymentEdit>
> <CIPBankAccountStored>0</CIPBankAccountStored>
> <CheckoutEnabled>1</CheckoutEnabled>
> <Email><![CDATA[gth...@we...]]></Email>
> <RegDate>2003-12-30 15:31:20</RegDate>
> <CountryCode>us</CountryCode>
> <Zip>94115</Zip>
> <UserId>mkgtest2</UserId>
> </User>
> </Buyer>
>
> This works fine:
>
> $user = $xpath->getData('/Buyer[1]/User[1]/UserId[1]/');
> $user = $xpath->getData('/Buyer[1]/User[1]/UserId[1]/text()!!');
> return is "mkgtest2".
> For the element "Email" i have not found anything that returns
> "gth...@we...".
> I tried:
> $user = $xpath->match('//Email');
> It returns Array ( [0] => /Buyer[1]/User[1]/Email[1] )
> Ok, that's fine, but when i try to use that xpath in
> $user = $xpath->getData('/Buyer[1]/User[1]/Email[1]');
> or
> $user = $xpath->getData('/Buyer[1]/User[1]/Email[1]/text()!!');
> i get nothing, not even an error.
are you absolutely sure you get nothing? Try:
<?php
include('XPath.class.php');
$xml = new XPath();
$xml->importFromFile('whatever.xml');
print htmlspecialchars($xml->getData('/Buyer[1]/User[1]/Email[1]'));
?>
:-)
|