Beispiel #1
0
func parseXPath(doc *dom.Document, request string) (*xmlpath.Node, *xmlpath.Path, error) {
	content := strings.NewReader(doc.String())
	node, err := xmlpath.Parse(content)
	if err != nil {
		return nil, nil, err
	}

	path, err := xmlpath.CompileWithNamespace(request, soap.GetAllNamespaces())
	if err != nil {
		return nil, nil, err
	}

	return node, path, nil
}
Beispiel #2
0
func assertXPath(c *C, node *dom.Document, request string, expected string) {
	content := strings.NewReader(node.String())

	path, err := xmlpath.CompileWithNamespace(request, soap.GetAllNamespaces())
	if err != nil {
		c.Fatalf("Xpath %s gives error %s", request, err)
	}
	var root *xmlpath.Node
	root, err = xmlpath.Parse(content)
	if err != nil {
		c.Fatalf("Xpath %s gives error %s", request, err)
	}

	var e string
	var ok bool
	e, ok = path.String(root)
	c.Assert(ok, Equals, true)
	c.Assert(e, Equals, expected)
}