| 565 | } |
| 566 | |
| 567 | func TestQueryWithPrefix(t *testing.T) { |
| 568 | s := `<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body test="1"><ns2:Fault xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.w3.org/2003/05/soap-envelope"><faultcode>ns2:Client</faultcode><faultstring>This is a client fault</faultstring></ns2:Fault></S:Body></S:Envelope>` |
| 569 | doc, _ := Parse(strings.NewReader(s)) |
| 570 | n, err := Query(doc, `//S:Envelope/S:Body/ns2:Fault/faultcode`) |
| 571 | if err != nil { |
| 572 | t.Fatal(err) |
| 573 | } |
| 574 | if n == nil { |
| 575 | t.Fatalf("should found one but got nil") |
| 576 | } |
| 577 | if expected, v := "ns2:Client", n.InnerText(); expected != v { |
| 578 | t.Fatalf("expected %s but got %s", expected, v) |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | func TestOutputXMLWithCommentNode(t *testing.T) { |
| 583 | s := `<?xml version="1.0" encoding="utf-8"?> |