Icon ParseXML

Unit: WebCore

Available In: Client Applications

function ParseXML(const Value: String): TDocument

The ParseXML function parses the XML string input parameter and returns a TDocument class instance.

Information Please refer to the WebDOM unit source code for the declaration of the TNode, TDocument, and TNodeList classes and their various properties.

Examples

var
   TempXML: String;
   TempDocument: TDocument;
   TempNodes: TNodeList;
begin
   TempXML := '<a><b><c><username>testuser</username></c></b></a>';
   TempDocument := ParseXML(TempXML);
   TempNodes := TempDocument.getElementsByTagName('username');
   ShowMessage(IntToStr(TempNodes.length)); // Number of nodes
   ShowMessage(TempNodes[0].firstChild.nodeValue); // Get text node
   TempXML := SerializeXML(TempDocument);
   ShowMessage(TempXML);
end
Image