Processing instructions don't seem to be handled correctly
cideM opened this issue · comments
Florian Beeres commented
The snippet below gives me
$ go run main.go
<item><para>first</para><?xe-change-remove-start?><item><para>second</para></item></item>
<?xml version="1.0" encoding="UTF-8"?><list><item><para>first</para><?xe-change-remove-start?><item><para>second</para></item></item></list>
notices that the item
nesting is broken. It looks to me as if the input parsing was already broken.
package main
import (
"fmt"
"strings"
"github.com/antchfx/xmlquery"
)
func main() {
s := `
<?xml version="1.0" encoding="UTF-8" ?>
<list>
<item><para>first</para></item>
<?xe-change-remove-start?>
<item><para>second</para></item>
</list>
`
doc, err := xmlquery.Parse(strings.NewReader(s))
if err != nil {
panic(err)
}
list := xmlquery.FindOne(doc, "//list")
for c := list.FirstChild; c != nil; c = c.NextSibling {
fmt.Println(c.OutputXML(true))
}
fmt.Println(doc.OutputXMLWithOptions(xmlquery.WithEmptyTagSupport(), xmlquery.WithOutputSelf()))
}