Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Incorrect element name when creating element using CreateElementNS without namespace prefix #104

Closed
guitarpawat opened this issue Jun 26, 2024 · 2 comments
Assignees
Labels

Comments

@guitarpawat
Copy link

Describe the bug

When creating new elements using function CreateElementNS without a namespace prefix, it creates a new node with an incorrect name.

To Reproduce / Expected behavior

package main

import (
	"fmt"
	"github.com/lestrrat-go/libxml2/dom"
)

func main() {
	root := dom.CreateDocument()
	doc, err := root.CreateElementNS("https://example.com", "Document")
	if err != nil {
		fmt.Println("err:", err)
		return
	}
	_ = root.SetDocumentElement(doc)
	test, _ := root.CreateElementNS("https://example.com", "A")
	_ = doc.AddChild(test)
	fmt.Println(root.Dump(true))
}

Output:

<?xml version="1.0" encoding="utf-8"?>
<Documen: xmlns:Documen="https://example.com">
  <: xmlns:="https://example.com"/>
</Documen:>

There are two possible solutions

  1. Return an error if there is no namespace prefix.
  2. Create an element using the default namespace.
Copy link

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 11, 2024
Copy link

This issue was closed because it has been stalled for 7 days with no activity. This does not mean your issue is rejected, but rather it is done to hide it from the view of the maintains for the time being. Feel free to reopen if you have new comments

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants