antchfx / xmlquery

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

Some text nodes not present in tree after parsing - seems to be mixed content with formatted xml #63

Open max-carroll opened 3 years ago

max-carroll commented 3 years ago
func Test_MyTest(t *testing.T) {
    assert := assert.New(t)
    inputHtml := `
    <a>
      <b>hello</b>
        my friend
  </a>`

    topNode, _ := xmlquery.Parse(strings.NewReader(inputHtml))

      //  `my friend` should be a sibling with <b> or a child of <a> but it is neither and unobtainable from the tree structure
}
max-carroll commented 3 years ago

One thing thats notable is if we remove all the whitespace, the my friend node is within the tree structure

zhengchun commented 3 years ago

Hello, which version are you using? I test on my machine with the latest version, the output is not problem.

output: <?xml?><a><b>hello</b>my friend</a>

galtm commented 3 years ago

@max-carroll : Now that v1.3.7 has been released with the fix in PR #62 , I wonder if that fixes this issue.