| 140 | } |
| 141 | |
| 142 | func 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 | |
| 165 | func TestDuplicateNamespaceURL(t *testing.T) { |
| 166 | s := `<?xml version='1.0' encoding='UTF-8'?> |