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

Function TestNamespaceURL

parse_test.go:188–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestNamespaceURL(t *testing.T) {
189 s := `
190<?xml version="1.0"?>
191<rss version="2.0" xmlns="http://www.example.com/" xmlns:dc="https://purl.org/dc/elements/1.1/">
192<!-- author -->
193<dc:creator><![CDATA[Richard ]]><![CDATA[Lawler]]></dc:creator>
194<dc:identifier>21|22021348</dc:identifier>
195</rss>
196 `
197 doc, err := Parse(strings.NewReader(s))
198 if err != nil {
199 t.Fatal(err)
200 }
201 top := FindOne(doc, "//rss")
202 if top == nil {
203 t.Fatal("rss feed invalid")
204 }
205 node := FindOne(top, "dc:creator")
206 if node.Prefix != "dc" {
207 t.Fatalf("expected node prefix name is dc but is=%s", node.Prefix)
208 }
209 if node.NamespaceURI != "https://purl.org/dc/elements/1.1/" {
210 t.Fatalf("dc:creator != %s", node.NamespaceURI)
211 }
212 if strings.Index(top.InnerText(), "author") > 0 {
213 t.Fatalf("InnerText() include comment node text")
214 }
215 if !strings.Contains(top.OutputXML(true), "author") {
216 t.Fatal("OutputXML shoud include comment node,but not")
217 }
218}
219
220func TestMultipleProcInst(t *testing.T) {
221 s := `<?xml version="1.0" encoding="UTF-8"?>

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.85
FindOneFunction · 0.85
InnerTextMethod · 0.80
OutputXMLMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…