EDN Admin
Well-known member
Hi
I have a xml document like this. I I trying to select all attributes with name attr1.
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; root <span style="color:Red; xmlns:my<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; helloworld<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; e1 <span style="color:Red; my:attr1<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 123<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; e2 <span style="color:Red; my:attr1<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 456<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; e3 <span style="color:Red; my:attr2<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 123<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; root<span style="color:Blue; >
[/code]
I would expect this to work<br/>
"//my:*@my:attr1"
but .net 4 throws exception xpath has invalid token
/my:root/my:e1@my:attr1 throws xpath has invalid token
The answer is <a rel="nofollow //@my:attr1
Whats suprising to me is the // and @ right next to each other.
Still - learnt something new today.
HTH<br/>
Martin
View the full article
I have a xml document like this. I I trying to select all attributes with name attr1.
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; root <span style="color:Red; xmlns:my<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; helloworld<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; e1 <span style="color:Red; my:attr1<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 123<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; e2 <span style="color:Red; my:attr1<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 456<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; e3 <span style="color:Red; my:attr2<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 123<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; my<span style="color:Blue; :<span style="color:#A31515; root<span style="color:Blue; >
[/code]
I would expect this to work<br/>
"//my:*@my:attr1"
but .net 4 throws exception xpath has invalid token
/my:root/my:e1@my:attr1 throws xpath has invalid token
The answer is <a rel="nofollow //@my:attr1
Whats suprising to me is the // and @ right next to each other.
Still - learnt something new today.
HTH<br/>
Martin
View the full article