Skip to content

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

@cideM

Description

@cideM

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()))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions