Vattic
05-25-2008, 02:57 AM
I have been using a method similar to the following to select elements:
var allTags, thisTag;
allTags = document.evaluate(
"//table[@name='stats']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
Then using a for loop to loop through them. I have been told this isn't the best way to select elements but this is the way I know best.
The problem I am having is I want to know how to do the same but match multiple attribute values and also only select elements that do not have certain attributes.
So say I wanted to select a only the second table in the following code:
<table width="360" cellpadding="2">
</table>
<table width="360">
</table>
<table width="360" cellpadding="0">
</table>
So I want to select the table with a width of 360 which has no padding attribute.
Cheers in advance.
var allTags, thisTag;
allTags = document.evaluate(
"//table[@name='stats']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
Then using a for loop to loop through them. I have been told this isn't the best way to select elements but this is the way I know best.
The problem I am having is I want to know how to do the same but match multiple attribute values and also only select elements that do not have certain attributes.
So say I wanted to select a only the second table in the following code:
<table width="360" cellpadding="2">
</table>
<table width="360">
</table>
<table width="360" cellpadding="0">
</table>
So I want to select the table with a width of 360 which has no padding attribute.
Cheers in advance.