Re: [PHP] Re: Xpath arguments in variable

2010-09-16 Thread Pete Ford

On 15/09/10 18:00, David Harkness wrote:

And let's not forget

$v = $row-xpath(//membernumber[. = \$MemberId\]);

The \ inside the string turns into a double-quote and using  to delimit
the string allows for variable substitution.



Oooh, I hate using backslashes - they always seem so untidy...
I have a pathological fear of sed scripts, too. :(


--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] Re: Xpath arguments in variable

2010-09-16 Thread David Harkness
On Thu, Sep 16, 2010 at 1:20 AM, Pete Ford p...@justcroft.com wrote:

 On 15/09/10 18:00, David Harkness wrote:

 $v = $row-xpath(//membernumber[. = \$MemberId\]);


 Oooh, I hate using backslashes - they always seem so untidy...
 I have a pathological fear of sed scripts, too. :(


And yet I find them the *most* tidy in a way: \ inserts an actual
double-quote into the string. I don't think that's any more magical than
surround it with single-quotes so it doesn't terminate the string. It will
work in single- and double-quoted strings equally, so you don't have to
worry about switching from one to the other messing up the expression.

David


[PHP] Re: Xpath arguments in variable

2010-09-15 Thread Sridhar Pandurangiah


 Original Message 
Subject: Re: Xpath arguments in variable
From: php-gene...@garydjones.name (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)

Whats wrong with
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
?

Am I not understanding what you are trying to ask?



I tried this but doesn't work. I guess the above statement is 
concatenating the entire string and the substitution isn't happening


What I am trying to do is as follows
$MemberId = 'A192';
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

The $MemberId should be substituted with A192 and then the xpath query 
should be executed. The result should be that I locate the membernumber 
XML element that has the value A912.


Best regards

Sridhar



Sridhar Pandurangiah wrote:

now I need to pass this value to XPath within a string variable say

$v = $row-xpath('//membernumber[. = $MemberId]');

But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.


Whats wrong with 
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

?

Am I not understanding what you are trying to ask?



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



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread Ashley Sheridan
On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:

  Original Message 
 Subject: Re: Xpath arguments in variable
 From: php-gene...@garydjones.name (Gary)
 To:
 Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
 
 Whats wrong with
 $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
 ?
 
 Am I not understanding what you are trying to ask?
 
 
 
 I tried this but doesn't work. I guess the above statement is 
 concatenating the entire string and the substitution isn't happening
 
 What I am trying to do is as follows
 $MemberId = 'A192';
 $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
 
 The $MemberId should be substituted with A192 and then the xpath query 
 should be executed. The result should be that I locate the membernumber 
 XML element that has the value A912.
 
 Best regards
 
 Sridhar
 
 
  Sridhar Pandurangiah wrote:
  now I need to pass this value to XPath within a string variable say
 
  $v = $row-xpath('//membernumber[. = $MemberId]');
 
  But this doesnt work due to the quotes. What I intend PHP to do is to
  substitute the value for $MemberId and then execute the XPath query. I
  have grappled with it for a few days before posting this.
  
  Whats wrong with 
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
  ?
  
  Am I not understanding what you are trying to ask?
  
 


Did you try using double quotes?

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Re: Xpath arguments in variable

2010-09-15 Thread Pete Ford
If you needed the double-quotes in the Xpath expression when the constant is 
used , then you probably need them in the variable version.


$v = $row-xpath('//membernumber[. = '.$MemberId.']');

That should put the double-quotes in for you...

On 15/09/10 09:33, Sridhar Pandurangiah wrote:


 Original Message 
Subject: Re: Xpath arguments in variable
From: php-gene...@garydjones.name (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)

Whats wrong with
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
?

Am I not understanding what you are trying to ask?



I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening

What I am trying to do is as follows
$MemberId = 'A192';
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.

Best regards

Sridhar



Sridhar Pandurangiah wrote:

now I need to pass this value to XPath within a string variable say

$v = $row-xpath('//membernumber[. = $MemberId]');

But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.


Whats wrong with $v = $row-xpath('//membernumber[. = ' . $MemberId .
']');
?

Am I not understanding what you are trying to ask?




--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread Sridhar Pandurangiah

Managed to resolve it. Phew!

$v = $row-xpath('//membernumber[. = ' . '' . $MemberId . '' . ']');

works.

Best regards

Sridhar


 Original Message 
Subject: Re: [PHP] Re: Xpath arguments in variable
From: a...@ashleysheridan.co.uk (Ashley Sheridan)
To:
Date: Wed Sep 15 2010 14:04:33 GMT+0530 (IST)


On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:


 Original Message 
Subject: Re: Xpath arguments in variable
From: php-gene...@garydjones.name (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)

Whats wrong with
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
?

Am I not understanding what you are trying to ask?



I tried this but doesn't work. I guess the above statement is 
concatenating the entire string and the substitution isn't happening


What I am trying to do is as follows
$MemberId = 'A192';
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

The $MemberId should be substituted with A192 and then the xpath query 
should be executed. The result should be that I locate the membernumber 
XML element that has the value A912.


Best regards

Sridhar



Sridhar Pandurangiah wrote:

now I need to pass this value to XPath within a string variable say

$v = $row-xpath('//membernumber[. = $MemberId]');

But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with 
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

?

Am I not understanding what you are trying to ask?




Did you try using double quotes?

Thanks,
Ash
http://www.ashleysheridan.co.uk





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



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread Ashley Sheridan
On Wed, 2010-09-15 at 14:27 +0530, Sridhar Pandurangiah wrote:
 Managed to resolve it. Phew!
 
 $v = $row-xpath('//membernumber[. = ' . '' . $MemberId . '' . ']');
 
 works.
 
 Best regards
 
 Sridhar
 
 
  Original Message 
 Subject: Re: [PHP] Re: Xpath arguments in variable
 From: a...@ashleysheridan.co.uk (Ashley Sheridan)
 To:
 Date: Wed Sep 15 2010 14:04:33 GMT+0530 (IST)
 
  On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:
  
   Original Message 
  Subject: Re: Xpath arguments in variable
  From: php-gene...@garydjones.name (Gary)
  To:
  Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
 
  Whats wrong with
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
  ?
 
  Am I not understanding what you are trying to ask?
 
  
 
  I tried this but doesn't work. I guess the above statement is 
  concatenating the entire string and the substitution isn't happening
 
  What I am trying to do is as follows
  $MemberId = 'A192';
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
 
  The $MemberId should be substituted with A192 and then the xpath query 
  should be executed. The result should be that I locate the membernumber 
  XML element that has the value A912.
 
  Best regards
 
  Sridhar
 
 
  Sridhar Pandurangiah wrote:
  now I need to pass this value to XPath within a string variable say
 
  $v = $row-xpath('//membernumber[. = $MemberId]');
 
  But this doesnt work due to the quotes. What I intend PHP to do is to
  substitute the value for $MemberId and then execute the XPath query. I
  have grappled with it for a few days before posting this.
  Whats wrong with 
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
  ?
 
  Am I not understanding what you are trying to ask?
 
  
  
  Did you try using double quotes?
  
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
  
  
  
 
Wouldn't

$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

be better? You're breaking the string into too many parts for now
reason.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread David Harkness
And let's not forget

$v = $row-xpath(//membernumber[. = \$MemberId\]);

The \ inside the string turns into a double-quote and using  to delimit
the string allows for variable substitution.