xmlDocumentFromString()

Reads the complete content from a string and builds the DOM structure in memory.

Synopsis

int xmlDocumentFromString(string xml, string &errMsg, int &errLine, int &errColumn);

Parameters

Parameter Description
xml String that is read
errMsg Alert message of the failure
errLine Line in the document where the failure occurred.
errColumn Column in the document where the failure occurred.

Return value

Returns a document ID which will be passed in future other XML calls.

If an error occurs, -1 will be returned.

Description

Reads the complete content from a string and builds the DOM structure in memory. The returned ID is valid until a call of xmlCloseDocument().

In case of an error, errMsg, errLine, errColumn contain a reference to the position where the parsing failed.

All conventions, which count within a string have to be also factored in the XML code text (e.g. set a backslash (\) previous to a quote sign (")).

Example

#uses "CtrlXml"
main()
{
  int Id;
  string xmlD= "<?xml version=\"1.0\"
  encoding=\"UTF-8\"?><panel><properties><prop
  name=\"Size\" >500 400</prop><prop
  name=\"BackColor\" >_3DFace</prop><prop
  name=\"RefPoint\" >-1 -1</prop><prop
  name=\"InitAndTermRef\" >True</prop><prop
  name=\"SendClick\"
  >False</prop></properties></panel>";
  //Note that the string may not be split on several lines
  string errMsg;
  int errLine, errColumn;
  Id = xmlDocumentFromString(xmlD, errMsg, errLine,
  errColumn);
  DebugN("Document ID:", Id);
  DebugN("Errors:", errMsg, errLine, errColumn);
}

Assignment

XML Control Extension

Availability

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