go-xmlpath / xmlpath

Strict subset of the XPath specification for the Go language.
http://gopkg.in/xmlpath.v2
Other
115 stars 37 forks source link

Both Path.Iter and Path.String seems to ignore the Context #1

Closed mimrock closed 10 years ago

mimrock commented 10 years ago

I am working with HTML files(parsed with ParseHTML) and I think both Path.Iter() and Path.String() seems to ignore the context node I provide, and instead they look for the element as if the context was the whole document.

niemeyer commented 10 years ago

It definitely takes the node into account. Here is a simple example:

http://play.golang.org/p/YkAIR1ic3P

Alternatively, have a look at the code - there's no way the context argument can just be ignored.

mimrock commented 10 years ago

I'm not an expert in go. It's possible I made some obvious mistake. Could you please handle this as a support request, and help me with this one? http://pastebin.com/70YJAS1w

Expected output: Content of the context: First paragraph Result: First paragraph Content of the context: Second paragraph Result: Second paragraph

Observed output: Content of the context: First paragraph Result: First paragraph Content of the context: Second paragraph Result: First paragraph

Thank you!

John-Gee commented 9 years ago

Just wanted to say Thanks for the example! I was stuck on the same thing, and realized from your example that it was because I was starting my 2nd path with '/'. Without this it worked just fine.