Documentation
Parsing functions
TapHome script parsing functions — PARSETEXT, PARSEJSON, and PARSEXML for extracting values from text, JSON, and XML data.
PARSETEXT
Returns part of input text, based on left and right search patterns
PARSETEXT( input, left_pattern, right_pattern)Examples:
PARSETEXT(“Lorem ipsum dolor sit amet”, “ipsum”, “amet”) (Result is “dolor sit”)
PARSETEXT(“<temp>12.2</temp>”, “<temp>”, “</temp”) (Result is 12.2)
PARSETEXT(“<temp>12.2</temp>”, “<temp>”) (Result is 12.2)
PARSETEXT(“status:ok,error:none”, “status:”) (Result is “ok”)
PARSETEXT(“Lorem ipsum dolor sit amet”, “ipsum”) (Result is “dolor”)
PARSETEXT(“Lorem ipsum dolor sit amet”, “ipsum…sit”) (Result is “amet”)
PARSETEXT(“Lorem ipsum dolor sit amet consectetur adipiscing”, “ipsum…sit”, “adipiscing”) (Result is “amet consectetur”)PARSEJSON
Returns value of element from json formatted string. Element is specified with json path.
PARSEJSON( json_string, json_path, ignore_error)Examples:
With json =
| |
PARSEJSON(json, “firstName”) (Result is “John”)
PARSEJSON(json, “address.city”) (Result is “Nara”)
PARSEJSON(json, “address.country”) (error)
PARSEJSON(json, “address.country”, 0) (error)
PARSEJSON(json, “address.city”, 1) (Result is null)PARSEXML
Returns value of element from xml string. Element is specified with xml path.
PARSEXML( xml_string, xml_path)Examples:
With xml=
| |
PARSEXML(xml, "//catalog/book[1]/price") (Result is 44.95)
PARSEXML(xml, "//book[2]/title") (Result is "Midnight Rain")
PARSEXML(xml, "//book[1]/@id") (Result is "bk101")
PARSEXML(xml, "//catalog/magazine[1]/price") (Result is null)If xml contains namespaces, you have to fully specify element names with namespace, eg. PARSEXML(xml, “//DIDL-Lite:container[dc:title=‘My Playlist’’]/DIDL-Lite:res”);