Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node should select only 1 sibling #14

Closed
rightjoin opened this issue Aug 1, 2019 · 2 comments
Closed

node should select only 1 sibling #14

rightjoin opened this issue Aug 1, 2019 · 2 comments
Labels

Comments

@rightjoin
Copy link

Hi,

Please look at the following test case. When I select follow-sibling::child[1], then only the first child should be selected.

`func TestFetchSibling(t *testing.T) {

xml := `<?xml version="1.0" encoding="UTF-8"?>
<node>
	<element index="one"/>
	<hash attr="one"/>
	<element index="two"/>
	<hash attr="two"/>
</node>
`

doc, _ := xmlquery.Parse(strings.NewReader(xml))
ele1 := xmlquery.FindOne(doc, "//node/element")

// specify xpath to pick the first element only
hashes := xmlquery.Find(ele1, "following-sibling::hash[1]")
if len(hashes) != 1 {
	t.Errorf("lenght should be 1, but found %d", len(hashes))
}

}
`

@zhengchun zhengchun added the bug label Aug 2, 2019
zhengchun added a commit to antchfx/xpath that referenced this issue Aug 2, 2019
@zhengchun
Copy link
Contributor

fixed, Thanks report it. just getting the latest xpath package.

@rightjoin
Copy link
Author

That was super fast! Thanks

Love your library :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants