MCPcopy Create free account
hub / github.com/antchfx/xmlquery / TestOutputXMLWithCommentNode

Function TestOutputXMLWithCommentNode

node_test.go:582–607  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

580}
581
582func TestOutputXMLWithCommentNode(t *testing.T) {
583 s := `<?xml version="1.0" encoding="utf-8"?>
584 <!-- Students grades are updated bi-monthly -->
585 <class_list>
586 <student>
587 <name>Robert</name>
588 <grade>A+</grade>
589 </student>
590 <!--
591 <student>
592 <name>Lenard</name>
593 <grade>A-</grade>
594 </student>
595 -->
596 </class_list>`
597 doc, _ := Parse(strings.NewReader(s))
598 t.Log(doc.OutputXML(true))
599 if e, g := "<!-- Students grades are updated bi-monthly -->", doc.OutputXML(true); !strings.Contains(g, e) {
600 t.Fatal("missing some comment-node.")
601 }
602 n := FindOne(doc, "//class_list")
603 t.Log(n.OutputXML(false))
604 if e, g := "<name>Lenard</name>", n.OutputXML(false); !strings.Contains(g, e) {
605 t.Fatal("missing some comment-node")
606 }
607}
608
609func TestOutputXMLWithSpaceParent(t *testing.T) {
610 s := `<?xml version="1.0" encoding="utf-8"?>

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.85
FindOneFunction · 0.85
OutputXMLMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…