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

Processing instructions don't seem to be handled correctly #106

Open
cideM opened this issue Jun 19, 2023 · 0 comments
Open

Processing instructions don't seem to be handled correctly #106

cideM opened this issue Jun 19, 2023 · 0 comments
Labels

Comments

@cideM
Copy link

cideM commented Jun 19, 2023

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()))
}
@zhengchun zhengchun added the bug label Jun 19, 2023
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