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

How come this query does not return results? #4

Open
beatscode opened this issue Mar 18, 2018 · 2 comments
Open

How come this query does not return results? #4

beatscode opened this issue Mar 18, 2018 · 2 comments
Labels

Comments

@beatscode
Copy link

I'm trying to search for a node in a document
I think my xpath query is correct in syntax but does not return any elements. The following test fails.

func TestLayerIDFinding(t *testing.T) {
	xm :=
		`<?xml version="1.0" encoding="UTF-8"?><_signin.SignInButton X="28" Y="352" Width="320" Height="50" LayerID="7FD41E11-85C2-45CC-AFFA-E9D480F22503" />`
	node := xmldom.Must(xmldom.ParseXML(xm))
	xpath := `//_signin.SignInButton[@LayerID="7FD41E11-85C2-45CC-AFFA-E9D480F22503"]`
	r := node.Root.QueryOne(xpath)
	if r == nil {
		t.Error("Could Not find element")
	} else {
		t.Log("Element found")
	}
}

image

@beatscode
Copy link
Author

I was able to get this to work by changing LayerID to id and using FindByID. Curious if I should stay away from xpath queries like this?

@subchen
Copy link
Owner

subchen commented Mar 19, 2018

Seems to be a bug, that root node cannot be found using //... xpath.

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