antchfx / xmlquery

xmlquery is Golang XPath package for XML query.
https://github.com/antchfx/xpath
MIT License
444 stars 89 forks source link

XML QueryAll not finding all nodes #67

Closed vbisbest closed 7 months ago

vbisbest commented 3 years ago

I have an xml document and trying to pull all "con:resource" nodes out of it. For some reason, xmlquery is only finding 2 nodes when there are 8 that should be returned. "Find" has the same issue. I have tested this with an online xpath tool and it works properly.

r := bufio.NewReader(file)
doc, _ := xmlquery.Parse(r)
nodes, _ := xmlquery.QueryAll(doc, "/con:soapui-project/con:interface/con:resource")

Here is my XML document.

`<?xml version="1.0" encoding="UTF-8"?>

http://localhost:3008 application/json 405 415 act:Fault application/x-www-form-urlencoded application/json 400 data 400 data application/json 200 Response 400 data <xml-fragment/> http://localhost:3008 { "month": "1" } http://localhost/api/v1/activities/ No Authorization ISBN ISBN TEMPLATE ISBN application/json 200 ns:Response <xml-fragment/> http://localhost:3008 http://localhost/api/v1/books/978-93-80658-74-2/ No Authorization ID ID TEMPLATE ID application/json 401 ns:Fault text/plain 500 data application/json 200 ns:Response <xml-fragment/> http://localhost:3008 http://localhost/api/v1/exams/123/ Profile 1 OAuth 2.0 ID ID TEMPLATE ID 404 data application/json 200 ns:Response <xml-fragment/> http://localhost:3008 http://localhost/api/v1/articles/1/ No Authorization application/json application/json 401 adv:Fault application/json 201 adv:Response <xml-fragment/> http://localhost:3008 { "headline": "Test", "info": "Some Info", "price": 13.03 } http://localhost/api/v1/advertisements/ Profile 1 OAuth 2.0 application/json 401 adv:Fault application/json 200 Response <xml-fragment/> http://localhost:3008 http://localhost/api/v1/advertisements/ Profile 1 OAuth 2.0 application/json 405 tra:Fault application/json 200 tra:Response application/json <xml-fragment/> http://localhost:3008 { "PNR": "9875-4581-234" } http://localhost/api/v1/trains/ No Authorization application/json 405 tra:Fault application/json 200 tra:Response application/json <xml-fragment/> http://localhost:3008 { "PNR": "9875-4581-234" } http://localhost/api/v1/trains/ No Authorization SEQUENTIAL <xml-fragment/> http://localhost:3008 { "month": "1" } http://localhost/api/v1/activities/ Profile 1 OAuth 2.0 <xml-fragment/> http://localhost:3008 http://localhost/api/v1/books/978-93-80658-74-2/ Profile 1 OAuth 2.0 <xml-fragment/> http://localhost:3008 http://localhost/api/v1/exams/123/ Profile 1 OAuth 2.0 <xml-fragment/> http://localhost:3008 http://localhost/api/v1/articles/1/ Profile 1 OAuth 2.0 <xml-fragment/> http://localhost:3008 { "headline": "Test", "info": "Some Info", "price": 13.03 } http://localhost/api/v1/advertisements/ Profile 1 OAuth 2.0 <xml-fragment/> http://localhost:3008 http://localhost/api/v1/advertisements/ Profile 1 OAuth 2.0 <xml-fragment/> http://localhost:3008 { "PNR": "9875-4581-234" } http://localhost/api/v1/trains/ Profile 1 OAuth 2.0 Profile 1 ALGGN0UmsY2Gb9cs3V4CEKMfpBJ2D2XZQXuTFfND mWM7pgvjtUSAtfaK8RXLjzOaLmurBxIWxMdQIQ0t1fSv9orqOnYr5wP5CaFN8DE18NiFiKKalQPu1WecmpbfoZCGYhMqMACz6i2WkWYs5E8gjXxqekjCyPkhBmO5n5EN http://localhost:3008/oauth/token/ http://localhost:3008/oauth/token/ http://localhost:3008/oauth/token/ RoLnzPen7koSoKcife1m6tSSfmknHm HEADER RESOURCE_OWNER_PASSWORD_CREDENTIALS AUTOMATIC sdaitQ0rXgpy1nXEXskPr0sy42p37I RETRIEVED_FROM_SERVER RETRIEVED_FROM_SERVER 36000 1624624920 2 true HOURS batman Batman@123 `
zhengchun commented 3 years ago

The parser is parsing your XML file got an error, not get valid XML.