Added some more libxml2 examples to Fun. (0.35.1)
This commit is contained in:
parent
e65756226d
commit
db450a871c
8 changed files with 218 additions and 1 deletions
|
|
@ -37,3 +37,21 @@ class XML()
|
|||
// Get node concatenated text content as string.
|
||||
fun text(this, node)
|
||||
return xml_text(node)
|
||||
|
||||
// Utility: return substring of s between delimiters a and b.
|
||||
// - If a is not found, returns "".
|
||||
// - If b is an empty string, returns everything after the first occurrence of a.
|
||||
// - If b is not found after a, returns "".
|
||||
fun between(this, s, a, b)
|
||||
i = find(s, a)
|
||||
if (i < 0)
|
||||
return ""
|
||||
i = i + len(a)
|
||||
rest = substr(s, i, len(s) - i)
|
||||
if (len(b) == 0)
|
||||
return rest
|
||||
j = find(rest, b)
|
||||
if (j < 0)
|
||||
return ""
|
||||
return substr(rest, 0, j)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue