1
0
Fork 0
forked from fun/fun

Added some more libxml2 examples to Fun. (0.35.1)

This commit is contained in:
Johannes Findeisen 2025-12-09 04:31:41 +01:00
commit db450a871c
8 changed files with 218 additions and 1 deletions

View file

@ -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)