Re: [PHP] LoadXML trouble

2007-12-11 Thread Jochem Maas
Dani Castaños wrote:
> Hi Nathan!
> 
> Thank you for all your help!
> Problem has been fixed...
> 
> The thing is, when request is sent, there is a little difference in what
> i get... I get  and so on...
> These backslashes make the loadXML not load data properly... I've put an
> str_replace and the problem has been solved

ah, that will be this:

http://php.net/manual/en/ref.info.php#ini.magic-quotes-gpc

you have just learned to carefully study the differences between dev and 
production
php.ini settings (e.g. via phpinfo()) when you run into these kind of problems 
:-)

> 
> Again... Thank you very much!
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LoadXML trouble

2007-12-11 Thread Dani Castaños

Hi Nathan!

Thank you for all your help!
Problem has been fixed...

The thing is, when request is sent, there is a little difference in what 
i get... I get  and so on...
These backslashes make the loadXML not load data properly... I've put an 
str_replace and the problem has been solved


Again... Thank you very much!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LoadXML trouble

2007-12-11 Thread Dani Castaños



that is expected behavior.  some of the internal classes dont define
any member variables that the php language has access to.  obviously
they are storing data internally, said variables just arent accessible as
member variables of the class thats being defined.


Ok! Thank you for this info...

But then...
Why can i do this in Windows:
$xml->getElementsByTagName( 'ticketID' )->item( 0 )->nodeValue;

and not in Linux?

-- Xml example:


1197027955_8310
OK
200



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LoadXML trouble

2007-12-11 Thread Nathan Nobbe
On Dec 11, 2007 3:52 AM, Dani Castaños <[EMAIL PROTECTED]> wrote:

> If i use your script like this:
>
> $xml = '
> 
>  1197027955_8310
>  OK
>  200
>  
> ';
>
> $obj = new DOMDocument();
> $obj->loadXML( $xml );
>
> echo print_r( $obj, true );
> echo $obj->saveXML() . PHP_EOL;
>
> The first statement writes:
> DOMDocument Object
> (
> )
>
> The second:
> 
> 
>  1197027955_8310
>  OK
>  200
>  
> 
>
> It's just the xml is not properly stored in loadXML method... but the
> string must be inside due to saveXML returns the proper value.


that is expected behavior.  some of the internal classes dont define
any member variables that the php language has access to.  obviously
they are storing data internally, said variables just arent accessible as
member variables of the class thats being defined.
you can look at the structure of a class in one line with:
Reflection::export(new ReflectionClass('DomDocument'));

-nathan


Re: [PHP] LoadXML trouble

2007-12-11 Thread Dani Castaños

If i use your script like this:

$xml = '

 1197027955_8310
 OK
 200
 
';

$obj = new DOMDocument();
$obj->loadXML( $xml );

echo print_r( $obj, true );
echo $obj->saveXML() . PHP_EOL;

The first statement writes:
DOMDocument Object
(
)

The second:


 1197027955_8310
 OK
 200
 


It's just the xml is not properly stored in loadXML method... but the 
string must be inside due to saveXML returns the proper value.



Nathan Nobbe escribió:
On Dec 10, 2007 12:08 PM, Dani Castaños <[EMAIL PROTECTED] 
> wrote:


Yep, it works when i do saveXML, but not on loadXML step...


did the loadXML() method work in the test script i sent over in my 
last post?
if it does then something else is going on when loadXML() is called in 
the context

of your application.

The thing is... i'm trying to do something like this:

$request = $_POST['xml'];
$logger->debug( 'New ticket request' );

/**
 * Parse XML request to obtain values
 */
$xml = new DOMDocument();
//$xml->validateOnParse = true;
$xml->loadXML( $request );


you should always sanitize input.  at the very least you should be 
running $_POST['xml']

through a call to trim() before handing it to the DOMDocument  instance.

$request = trim($_POST['xml']);
$xml = new DOMDocument();
$xml->loadXML($request);

i suspect there is some garbage in or around the string contained in 
$_POST['xml'] that
the DomDocument instance doesnt like, therefore its not behaving the 
way youd anticipate.
for example if you modify the script i sent over last time by putting 
some spaces in between the
xml declaration and the opening tag of the envelope () you 
should see the following error

(or something similar [depending on the value of error_reporting])

Warning: DOMDocument::loadXML(): XML declaration allowed only at the 
start of the document in Entity,

line: 3 in /home/nathan/testDom.php on line 19

which consequently leads to


when invoking
echo $domDoc->saveXML() . PHP_EOL;
rather than


 1197026188_ec76
 KO
 500
 Internal Server Error


which is what you would expect.
-nathan
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] LoadXML trouble

2007-12-10 Thread ked
first, create "dealxml.php" with ansi charset : 


  ked 
  tickcenter 
  train 
  back 
  1197026188_ec76 
  KO 
  500 
  Internal Server Error 

XML;
$xml = new DOMDocument();
//$xml->validateOnParse = true;
$xml->loadXML( $r );
$customer_id   = $xml->getElementsByTagName( 'customerID' )->item( 0
)->nodeValue;
$app_name  = $xml->getElementsByTagName( 'appName' )->item( 0
)->nodeValue;
$ticket_type   = $xml->getElementsByTagName( 'ticketType' )->item( 0
)->nodeValue;
$ticket_action = $xml->getElementsByTagName( 'ticketAction' )->item( 0
)->nodeValue; 
$ticket_params = $xml->getElementsByTagName( 'parameters' )->item( 0
)->childNodes;
echo "$customer_id ";
echo "$app_name ";
echo "$ticket_typed ";
echo "$ticket_action ";
echo "$ticket_params ";
?>

IE output :  

Warning: DOMDocument::loadXML() [function.loadXML]: Input is not proper
UTF-8, indicate encoding ! in Entity, line: 4 in W:\www\test\dealxml.php on
line 26

next , saved the dealxml.php as UTF-8 charset, then it works well.

I think that  the xml resource should be encoded by utf-8 charset, right or
wrong  ?  

My OS : win2000 , simplified chinese. Dose the OS blight  "DOMDocument" ?


> -Original Message-
> From: Nathan Nobbe [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 11, 2007 1:25 AM
> To: Dani Castaños
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] LoadXML trouble
> 
> On Dec 10, 2007 12:08 PM, Dani Castaños 
> <[EMAIL PROTECTED]> wrote:
> 
> > Yep, it works when i do saveXML, but not on loadXML step...
> 
> 
> did the loadXML() method work in the test script i sent over 
> in my last post?
> if it does then something else is going on when loadXML() is 
> called in the context of your application.
> 
> The thing is... i'm trying to do something like this:
> >
> > $request = $_POST['xml'];
> > $logger->debug( 'New ticket request' );
> >
> > /**
> >  * Parse XML request to obtain values
> >  */
> > $xml = new DOMDocument();
> > //$xml->validateOnParse = true;
> > $xml->loadXML( $request );
> 
> 
> you should always sanitize input.  at the very least you 
> should be running $_POST['xml'] through a call to trim() 
> before handing it to the DOMDocument  instance.
> 
> $request = trim($_POST['xml']);
> $xml = new DOMDocument();
> $xml->loadXML($request);
> 
> i suspect there is some garbage in or around the string 
> contained in $_POST['xml'] that the DomDocument instance 
> doesnt like, therefore its not behaving the way youd anticipate.
> for example if you modify the script i sent over last time by 
> putting some spaces in between the xml declaration and the 
> opening tag of the envelope () you should see the 
> following error (or something similar [depending on the value 
> of error_reporting])
> 
> Warning: DOMDocument::loadXML(): XML declaration allowed only 
> at the start of the document in Entity,
> line: 3 in /home/nathan/testDom.php on line 19
> 
> which consequently leads to
> 
> 
> when invoking
> echo $domDoc->saveXML() . PHP_EOL;
> rather than
> 
> 
>  1197026188_ec76
>  KO
>  500
>  Internal Server Error
> 
> 
> which is what you would expect.
> -nathan
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LoadXML trouble

2007-12-10 Thread Nathan Nobbe
On Dec 10, 2007 12:08 PM, Dani Castaños <[EMAIL PROTECTED]> wrote:

> Yep, it works when i do saveXML, but not on loadXML step...


did the loadXML() method work in the test script i sent over in my last
post?
if it does then something else is going on when loadXML() is called in the
context
of your application.

The thing is... i'm trying to do something like this:
>
> $request = $_POST['xml'];
> $logger->debug( 'New ticket request' );
>
> /**
>  * Parse XML request to obtain values
>  */
> $xml = new DOMDocument();
> //$xml->validateOnParse = true;
> $xml->loadXML( $request );


you should always sanitize input.  at the very least you should be running
$_POST['xml']
through a call to trim() before handing it to the DOMDocument  instance.

$request = trim($_POST['xml']);
$xml = new DOMDocument();
$xml->loadXML($request);

i suspect there is some garbage in or around the string contained in
$_POST['xml'] that
the DomDocument instance doesnt like, therefore its not behaving the way
youd anticipate.
for example if you modify the script i sent over last time by putting some
spaces in between the
xml declaration and the opening tag of the envelope () you should
see the following error
(or something similar [depending on the value of error_reporting])

Warning: DOMDocument::loadXML(): XML declaration allowed only at the start
of the document in Entity,
line: 3 in /home/nathan/testDom.php on line 19

which consequently leads to


when invoking
echo $domDoc->saveXML() . PHP_EOL;
rather than


 1197026188_ec76
 KO
 500
 Internal Server Error


which is what you would expect.
-nathan


Re: [PHP] LoadXML trouble

2007-12-10 Thread Dani Castaños

Yep, it works when i do saveXML, but not on loadXML step...

The thing is... i'm trying to do something like this:

$request = $_POST['xml'];
$logger->debug( 'New ticket request' );

/**
* Parse XML request to obtain values
*/
$xml = new DOMDocument();
//$xml->validateOnParse = true;
$xml->loadXML( $request );

$customer_id   = $xml->getElementsByTagName( 'customerID' )->item( 0 
)->nodeValue;
$app_name  = $xml->getElementsByTagName( 'appName' )->item( 0 
)->nodeValue;
$ticket_type   = $xml->getElementsByTagName( 'ticketType' )->item( 0 
)->nodeValue;
$ticket_action = $xml->getElementsByTagName( 'ticketAction' )->item( 0 
)->nodeValue;
$ticket_params = $xml->getElementsByTagName( 'parameters' )->item( 0 
)->childNodes;


...

Nathan Nobbe escribió:
On Dec 10, 2007 11:40 AM, Dani Castaños <[EMAIL PROTECTED] 
> wrote:


I've checked $request previously and is not empty... it has
something like:



 1197026188_ec76
 KO
 500
 Internal Server Error



have you been testing this in the context of your application, or have 
you also

tried a focused test script?  i would try something trivial, like:



 1197026188_ec76
 KO
 500
 Internal Server Error

XML;

$domDoc = new DOMDocument();
$domDoc->loadXML($xml);
echo $domDoc->saveXML() . PHP_EOL;
?>

just to ensure the DOM extension is available and working as expected.

-nathan


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LoadXML trouble

2007-12-10 Thread Nathan Nobbe
On Dec 10, 2007 11:40 AM, Dani Castaños <[EMAIL PROTECTED]> wrote:

> I've checked $request previously and is not empty... it has something
> like:
>
> 
> 
>  1197026188_ec76
>  KO
>  500
>  Internal Server Error
> 
>

have you been testing this in the context of your application, or have you
also
tried a focused test script?  i would try something trivial, like:



 1197026188_ec76
 KO
 500
 Internal Server Error

XML;

$domDoc = new DOMDocument();
$domDoc->loadXML($xml);
echo $domDoc->saveXML() . PHP_EOL;
?>

just to ensure the DOM extension is available and working as expected.

-nathan


Re: [PHP] LoadXML trouble

2007-12-10 Thread Dani Castaños

I've checked $request previously and is not empty... it has something like:



 1197026188_ec76
 KO
 500
 Internal Server Error


The curious thing is that I've built this xml string with DOMDocument in 
my request... Then I suppose my Linux system has DOM support,


Nathan Nobbe escribió:
On Dec 10, 2007 4:48 AM, Dani Castaños <[EMAIL PROTECTED] 
> wrote:


Hi list!

I have a problem with DOMDocument loadXML method. I used Windows to
develop my applications, and nothing happens on it when i do
something like

$xml = new DOMDocument();
$xml->loadXML( $request );

Obviously, request is not empty...


have you checked the contents of $request on the production machine 
prior to

the invocation of loadXML() ?

But when I have upload this code to production machine ( which runs
under Debian ) it doesn't works properly, The DOMDocument Object
is empty...


are the systems running the same major version of  php; and have you 
verified

the linux system has DOM support?

-nathan


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LoadXML trouble

2007-12-10 Thread Nathan Nobbe
On Dec 10, 2007 4:48 AM, Dani Castaños <[EMAIL PROTECTED]> wrote:

> Hi list!
>
> I have a problem with DOMDocument loadXML method. I used Windows to
> develop my applications, and nothing happens on it when i do something
> like
>
> $xml = new DOMDocument();
> $xml->loadXML( $request );
>
> Obviously, request is not empty...


have you checked the contents of $request on the production machine prior to
the invocation of loadXML() ?

But when I have upload this code to production machine ( which runs
> under Debian ) it doesn't works properly, The DOMDocument Object is
> empty...


are the systems running the same major version of  php; and have you
verified
the linux system has DOM support?

-nathan