How to select multiple attributes for an XPath query

Possible duplicate:
How to select multiple attribute sets in an XML document using XPath?

My HTML is:

<table width="100%" cellpadding="6" cellspacing="0"> 

I want to select this table, specifying not only the width, but also using cellpadding and cellspacing ..

I am using this PHP code:

 $query = $xpath->query('//table[@width|@cellpadding|@cellspacing]'); 

but it still displays the whole html source instead of what I want.
help me please.

+4
source share
1 answer

It seems you do not want to select attributes, but check to see if there are all the attributes. I.e:.

  $query = $xpath->query('//table[@width and @cellpadding and @cellspacing]'); 

Or, if you want to specify a table specifically, check the attributes for specific values?

  $query = $xpath->query('//table[@width = "100%" and @cellpadding = "6" and @cellspacing = "0"]'); 
+8
source

All Articles