| 186 | } |
| 187 | |
| 188 | func 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 | |
| 220 | func TestMultipleProcInst(t *testing.T) { |
| 221 | s := `<?xml version="1.0" encoding="UTF-8"?> |