Closed
Description
Versions:
- github.com/antchfx/xmlquery v1.3.10
- github.com/antchfx/xpath v1.2.0
This test is failing:
func TestXPathAnd(t *testing.T) {
body := `
<top>
<child><name>Child1</name>
<toy>A</toy>
<toy>B</toy>
</child>
</top>`
root, err := xmlquery.Parse(strings.NewReader(body))
assert.NoError(t, err)
expr, err := xpath.Compile(`/top/child[toy[text() = "A"] and toy[text()="B"]]/name/text()`)
assert.NoError(t, err)
result := expr.Evaluate(xmlquery.CreateXPathNavigator(root))
switch rt := result.(type) {
case *xpath.NodeIterator:
assert.True(t, rt.MoveNext()). // Fails
fmt.Println("Value:", rt.Current().Value())
}
}
Compare this with standard macos xpath utility:
xpath -e '/top/child[toy[text() = "A"] and toy[text()="B"]]/name/text()'
<top>
<child><name>Child1</name>
<toy>A</toy>
<toy>B</toy>
</child>
</top>
Found 1 nodes in stdin:
-- NODE --
Child1