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

Function TestDefaultNamespace_3

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

Source from the content-addressed store, hash-verified

140}
141
142func TestDefaultNamespace_3(t *testing.T) {
143 // https://github.com/antchfx/xmlquery/issues/67
144 // Use the duplicate xmlns on the children element
145 s := `<?xml version='1.0' encoding='UTF-8'?>
146 <bk:books xmlns:bk="urn:loc.gov:books">
147 <bk:book>
148 <title>book 2</title>
149 </bk:book>
150 <bk:book>
151 <title xmlns="urn:loc.gov:books">book 2</title>
152 </bk:book>
153 </bk:books>
154`
155 doc, err := Parse(strings.NewReader(s))
156 if err != nil {
157 t.Fatal(err)
158 }
159 list := Find(doc, `/bk:books/bk:book`)
160 if found, expected := len(list), 2; found != expected {
161 t.Fatalf("should found %d bk:book but found %d", expected, found)
162 }
163}
164
165func TestDuplicateNamespaceURL(t *testing.T) {
166 s := `<?xml version='1.0' encoding='UTF-8'?>

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.85
FindFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…