xmlDocumentToString()

Returns the internal DOM tree as a string result.

Synopsis

string xmlDocumentToString(unsigned doc);

Parameters

Parameter Description
doc The document ID returned by e.g. xmlNewDocument().

Return value

If an error occurs, an empty string will be returned, otherwise the string result.

Description

Returns the internal DOM tree as a string result.

Example

#uses "CtrlXml"
main()
{
  unsigned doc;
  int ret;
  int rootId;
  int nodeType;
  int childId;
  string nodeTypeText;
  doc = xmlNewDocument();
  DebugN("doc", doc);
  rootId = xmlAppendChild(doc, -1, 1);
  //Node type definition
  nodeType = XML_ATTRIBUTE_NODE;
  nodeTypeText = "Attribute name";
  //Add child
  childId = xmlAppendChild(doc, rootId, nodeType,
  "name_"+nodeTypeText);
  DebugN("xmlAppendChild", nodeTypeText + "(" + nodeType + ")",
  childId);
  //Detect node type
  DebugN("xmlNodeType", childId, nodeTypeText+"("+nodeType+")",
  xmlNodeType(doc, childId));
  //Detect node name
  DebugN("xmlNodeName", childId, nodeTypeText+"("+nodeType+")",
  xmlNodeName(doc, childId));
  //Set value
  DebugN("xmlSetNodeValue", childId, xmlSetNodeValue(doc, childId,
  "Value_"+nodeTypeText));
  //Read value
  DebugN("xmlNodeValue", childId, xmlNodeValue(doc, childId));
  //Add attribute
  DebugN("xmlSetElementAttribute", childId,
  xmlSetElementAttribute(doc, childId, "attrib",
  "att_"+nodeTypeText));
  //Read attribute
  mapping m;
  m = xmlElementAttributes(doc, childId);
  DebugN("xmlSetElementAttribute", childId, m);
  //Write to string
  DebugN("xmlDocumentToString", xmlDocumentToString(doc));
  ret = xmlCloseDocument(doc);
  DebugN(ret);
}

Assignment

XML Control Extension

Availability

CTRL. In every script where the "CtrlXml" extension (#uses "CtrlXml") is used.