EDN Admin
Well-known member
Ok I am confused as how SelectSingleNode is working. Given the following code:
<div style="background-color:white; color:black
<pre><span style="colorrangered $xml <span style="color:gray = @
<a<span style="color:gray >
<aa id<span style="color:gray =<span style="color:#a31515 "0"<span style="color:gray >
<ab id<span style="color:gray =<span style="color:#a31515 "0"<span style="color:gray >
<ac<span style="color:gray >a<<span style="color:gray /ac<span style="color:gray >
<<span style="color:gray /ab<span style="color:gray >
<<span style="color:gray /aa<span style="color:gray >
<aa id<span style="color:gray =<span style="color:#a31515 "1"<span style="color:gray >
<ab id<span style="color:gray =<span style="color:#a31515 "1"<span style="color:gray >
<ac<span style="color:gray >2<<span style="color:gray /ac<span style="color:gray >
<<span style="color:gray /ab<span style="color:gray >
<<span style="color:gray /aa<span style="color:gray >
<<span style="color:gray /a<span style="color:gray >
@
<span style="colorrangered $aa <span style="color:gray = <span style="color:#a31515 "aa"
<span style="colorrangered $ab <span style="color:gray = <span style="color:#a31515 "ab"
<span style="colorrangered $ac <span style="color:gray = <span style="color:#a31515 "ac"
<span style="color:gray [<span style="color:teal System.Reflection.Assembly<span style="color:gray ]<span style="color:gray ::LoadWithPartialName(<span style="color:#a31515 "System.Xml.Linq") | Out<span style="color:gray -Null
<span style="colorrangered $xmlDoc <span style="color:gray = New<span style="color:gray -Object Xml.XmlDocument
<span style="colorrangered $xmlDoc.LoadXml(<span style="colorrangered $xml)
<span style="colorrangered $xmlNav <span style="color:gray = <span style="colorrangered $xmlDoc.CreateNavigator()
<span style="colorrangered $aa_node <span style="color:gray = <span style="colorrangered $xmlNav.SelectSingleNode(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $aa)
<span style="colorrangered $found <span style="color:gray = 0
<span style="color:blue foreach (<span style="colorrangered $ab_node <span style="color:blue in <span style="colorrangered $aa_node.Select(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $ab)) {
<span style="color:#a31515 "== LOOP =="
<span style="colorrangered $ab_node
<span style="color:blue if (<span style="colorrangered $ab_node.GetAttribute(<span style="color:#a31515 "id", <span style="color:#a31515 "") <span style="color:gray -eq <span style="color:#a31515 "1") {
<span style="color:#a31515 "----"
<span style="colorrangered $ab_node.SelectSingleNode(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $ac)
<span style="color:blue if (<span style="colorrangered $aa_node.SelectSingleNode(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $ac).InnerXml <span style="color:gray -ne <span style="color:#a31515 "2") {
<span style="colorrangered $found <span style="color:gray = 1
<span style="color:#a31515 "FOUND!!"
}
<span style="colorrangered $drive <span style="color:gray = <span style="colorrangered $aa_node
}
}
[/code]
I expect that it does not display "FOUND!!". This is because, I expect that $ab_node.SelectSingleNode("//"+$ac).InnerXml would be 2 since it was applied to the ab node whos id attribute is 1. Why is it going to the ab node whos id attribute
is 0?
Thanks,
A
p.s. is there a way of getting the ISE to use a tab instead of 4 spaces?
<
Adrian
View the full article
<div style="background-color:white; color:black
<pre><span style="colorrangered $xml <span style="color:gray = @
<a<span style="color:gray >
<aa id<span style="color:gray =<span style="color:#a31515 "0"<span style="color:gray >
<ab id<span style="color:gray =<span style="color:#a31515 "0"<span style="color:gray >
<ac<span style="color:gray >a<<span style="color:gray /ac<span style="color:gray >
<<span style="color:gray /ab<span style="color:gray >
<<span style="color:gray /aa<span style="color:gray >
<aa id<span style="color:gray =<span style="color:#a31515 "1"<span style="color:gray >
<ab id<span style="color:gray =<span style="color:#a31515 "1"<span style="color:gray >
<ac<span style="color:gray >2<<span style="color:gray /ac<span style="color:gray >
<<span style="color:gray /ab<span style="color:gray >
<<span style="color:gray /aa<span style="color:gray >
<<span style="color:gray /a<span style="color:gray >
@
<span style="colorrangered $aa <span style="color:gray = <span style="color:#a31515 "aa"
<span style="colorrangered $ab <span style="color:gray = <span style="color:#a31515 "ab"
<span style="colorrangered $ac <span style="color:gray = <span style="color:#a31515 "ac"
<span style="color:gray [<span style="color:teal System.Reflection.Assembly<span style="color:gray ]<span style="color:gray ::LoadWithPartialName(<span style="color:#a31515 "System.Xml.Linq") | Out<span style="color:gray -Null
<span style="colorrangered $xmlDoc <span style="color:gray = New<span style="color:gray -Object Xml.XmlDocument
<span style="colorrangered $xmlDoc.LoadXml(<span style="colorrangered $xml)
<span style="colorrangered $xmlNav <span style="color:gray = <span style="colorrangered $xmlDoc.CreateNavigator()
<span style="colorrangered $aa_node <span style="color:gray = <span style="colorrangered $xmlNav.SelectSingleNode(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $aa)
<span style="colorrangered $found <span style="color:gray = 0
<span style="color:blue foreach (<span style="colorrangered $ab_node <span style="color:blue in <span style="colorrangered $aa_node.Select(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $ab)) {
<span style="color:#a31515 "== LOOP =="
<span style="colorrangered $ab_node
<span style="color:blue if (<span style="colorrangered $ab_node.GetAttribute(<span style="color:#a31515 "id", <span style="color:#a31515 "") <span style="color:gray -eq <span style="color:#a31515 "1") {
<span style="color:#a31515 "----"
<span style="colorrangered $ab_node.SelectSingleNode(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $ac)
<span style="color:blue if (<span style="colorrangered $aa_node.SelectSingleNode(<span style="color:#a31515 "//"<span style="color:gray +<span style="colorrangered $ac).InnerXml <span style="color:gray -ne <span style="color:#a31515 "2") {
<span style="colorrangered $found <span style="color:gray = 1
<span style="color:#a31515 "FOUND!!"
}
<span style="colorrangered $drive <span style="color:gray = <span style="colorrangered $aa_node
}
}
[/code]
I expect that it does not display "FOUND!!". This is because, I expect that $ab_node.SelectSingleNode("//"+$ac).InnerXml would be 2 since it was applied to the ab node whos id attribute is 1. Why is it going to the ab node whos id attribute
is 0?
Thanks,
A
p.s. is there a way of getting the ISE to use a tab instead of 4 spaces?
<
Adrian
View the full article