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

Function TestQueryWithPrefix

node_test.go:567–580  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

565}
566
567func 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
582func TestOutputXMLWithCommentNode(t *testing.T) {
583 s := `<?xml version="1.0" encoding="utf-8"?>

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.85
QueryFunction · 0.85
InnerTextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…