Xml

XML document, element, attribute, parser-result, and serialization helpers.


Core schemas


XMLParserResult


Parser model


parseStringToXML (source -- result)

Parses one accepted UTF-8 source into XMLParserResult.


saveXMLToString (xml -- string)

Serializes one XMLDocument to a formatted String.


Examples

Successful parse and stored counts

"Xml" use
"control" use

{} () {} [
  result: "" parseStringToXML;
  @result.@success TRUE same printStack _:;
  @result.@finished TRUE same printStack _:;
  @result.@xml.@[email protected] 1 same printStack _:;
  @result.@[email protected] 1 same printStack _:;
] "main" exportFunction

Expected Output During Compilation

TRUE
TRUE
TRUE
TRUE

Trailing input, duplicate attribute, discarded whitespace-only child data, and unsupported reference

"Xml" use
"control" use

{} () {} [
  trailing: "x" parseStringToXML;
  @trailing.@success TRUE same printStack _:;
  @trailing.@finished FALSE same printStack _:;

  duplicate: "" parseStringToXML;
  @duplicate.@success FALSE same printStack _:;

  spaces: "   " parseStringToXML;
  @spaces.@[email protected] 0 same printStack _:;

  apos: "'" parseStringToXML;
  @apos.@success FALSE same printStack _:;
] "main" exportFunction

Expected Output During Compilation

TRUE
TRUE
TRUE
TRUE
TRUE

Runtime example

"Xml" use
"String" use
"control" use

{} Int32 {} [
  result: "" parseStringToXML;
  ("success=" result.success LF
   "finished=" result.finished LF
   "attrs=" result.xml.root.attributes.size LF
   "children=" result.xml.root.children.size LF) printList
  0
] "main" exportFunction

Expected Output

success=TRUE
finished=TRUE
attrs=1
children=1

See also