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

Function TestDefaultNamespace_2

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

Source from the content-addressed store, hash-verified

115}
116
117func TestDefaultNamespace_2(t *testing.T) {
118 s := `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
119 <svg
120 xmlns="http://www.w3.org/2000/svg"
121 xmlns:svg="http://www.w3.org/2000/svg"
122 >
123 <text xml:space="preserve">
124 <tspan>Multiline</tspan>
125 <tspan>Multiline text</tspan>
126 </text>
127 </svg>`
128
129 doc, err := Parse(strings.NewReader(s))
130 if err != nil {
131 t.Fatal(err)
132 }
133 if n := FindOne(doc, "//svg"); n == nil {
134 t.Fatal("should find a `svg` but got nil")
135 }
136 list := Find(doc, "//tspan")
137 if found, expected := len(list), 2; found != expected {
138 t.Fatalf("should found %d tspan but found %d", expected, found)
139 }
140}
141
142func TestDefaultNamespace_3(t *testing.T) {
143 // https://github.com/antchfx/xmlquery/issues/67

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.85
FindOneFunction · 0.85
FindFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…