...
Code Block | ||
---|---|---|
| ||
"meta": [{ "context": "First", "fieldName": "test1", "scriptlang": "xpath", "script": "//a[1]" }, { "context": "First", "fieldName": "test2", // as above but with: "flags": "o" // formerly "groupNum": -1 }, { "context": "First", "fieldName": "test2", // as above but with: "flags": "x" } ] |
would generate the following different outputs:
Code Block | ||
---|---|---|
| ||
"metadata": { "test1": [ "BBC" ], "test2": [{ "href": "http://www.bbc.com", "content": "BBC" }], "hreftest3":"<a href=\"http://www.bbc.com", "content": "BBC" }] }\">BBC</a>" } |
For reference, here is the complete set of flags for xpath (and regex, except for "O"):
- 'H': will HTML-decode resulting fields. (Eg "&" -> "&")
- 'o': if the XPath expression points to an HTML (/XML) object, then this object is converted to JSON and stored as an object in the corresponding metadata field array. (Can also be done via the deprecated "groupNum":-1)
- 'x': if the XPath expression points to an HTML (/XML) object, then the XML of the object is displayed with no decoding (eg stripping of fields)
- 'D': described above
- 'c': if set then fields with the same name are chained together (otherwise they will all append their results to the field within metadata)
...