MCPcopy Index your code
hub / github.com/crowdsecurity/crowdsec / XMLGetNodeValue

Function XMLGetNodeValue

pkg/exprhelpers/xml.go:105–128  ·  view source on GitHub ↗

func XMLGetNodeValue(xmlString string, path string) string {

(params ...any)

Source from the content-addressed store, hash-verified

103
104// func XMLGetNodeValue(xmlString string, path string) string {
105func XMLGetNodeValue(params ...any) (any, error) {
106 xmlString := params[0].(string)
107 path := params[1].(string)
108
109 compiledPath, err := compileOrGetPath(path)
110 if err != nil {
111 log.Errorf("Could not compile path %s: %s", path, err)
112 return "", nil
113 }
114
115 doc, err := getXMLDocumentFromCache(xmlString)
116 if err != nil {
117 log.Tracef("Could not parse XML: %s", err)
118 return "", nil
119 }
120
121 elem := doc.FindElementPath(compiledPath)
122 if elem == nil {
123 log.Debugf("Could not find element %s", path)
124 return "", nil
125 }
126
127 return elem.Text(), nil
128}

Callers 2

TestLiveAcquisitionFunction · 0.92
TestXMLGetNodeValueFunction · 0.85

Calls 4

compileOrGetPathFunction · 0.85
getXMLDocumentFromCacheFunction · 0.85
TracefMethod · 0.80
TextMethod · 0.80

Tested by 2

TestLiveAcquisitionFunction · 0.74
TestXMLGetNodeValueFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…