| 522 | } |
| 523 | |
| 524 | func TestHtmlUnescapeStringOriginStringWrite(t *testing.T) { |
| 525 | // has escape html character and \t |
| 526 | data := `<?xml version="1.0" encoding="utf-8"?> |
| 527 | <example xml:space="preserve"><word>&#48; </word></example>` |
| 528 | |
| 529 | root, err := Parse(strings.NewReader(data)) |
| 530 | if err != nil { |
| 531 | t.Error(err) |
| 532 | } |
| 533 | |
| 534 | var b strings.Builder |
| 535 | err = root.Write(&b, false) |
| 536 | testTrue(t, err == nil) |
| 537 | escapedInnerText := b.String() |
| 538 | unescapeString := html.UnescapeString(escapedInnerText) |
| 539 | if strings.Contains(unescapeString, "&") { |
| 540 | t.Fatal("& need unescape") |
| 541 | } |
| 542 | if !strings.Contains(escapedInnerText, "&#48;\t\t") { |
| 543 | t.Fatal("Inner Text should keep plain text") |
| 544 | } |
| 545 | |
| 546 | } |
| 547 | |
| 548 | func TestOutputXMLWithNamespacePrefix(t *testing.T) { |
| 549 | s := `<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body></S:Body></S:Envelope>` |