Script example

The following example uses objects from the Microsoft XML Object Library to create an XML document from a record displayed in the Sellers window of the Real Estate Sales Manager application. The XML document is saved as SELLERS.XML.

local MSXML.DOMDocument xmlDoc;
local MSXML.IXMLDOMProcessingInstruction procInstruct;
local MSXML.IXMLDOMElement docElement;
local MSXML.IXMLDOMElement fieldElement;
local MSXML.IXMLDOMText textNode;

{If a record is not displayed, warn the user. Otherwise, create an XML document.}
if 'Seller ID' = "" then
	warning "Please display a record in the Sellers window.";
else

	{Create an XML document.}
	xmlDoc = new MSXML.DOMDocument();

	{Create the document prolog and append it to the document.}
	procInstruct = xmlDoc.createProcessingInstruction("xml",  "version =" + QUOTE + "1.0" + QUOTE);
	xmlDoc.appendChild(procInstruct);

	{Create the document element and append it to the XML document.}
	docElement = xmlDoc.createElement("Sellers");
	xmlDoc.appendChild(docElement);

	{Create a Seller ID element.}
	fieldElement = xmlDoc.createElement("Seller_ID");

	{Create a text node containing data from the Seller ID field and
	append it to the Seller ID element.}
	textNode = xmlDoc.createTextNode(str('Seller ID'));
	fieldElement.appendChild(textNode);

	{Append the Seller ID element to the document element.}
	docElement.appendChild(fieldElement);

	{Create a Seller First Name element.}
	fieldElement = xmlDoc.createElement("Seller_First_Name");

	{Create a text node containing data from the Seller First Name 
	field and append it to the Seller First Name element.}
	textNode = xmlDoc.createTextNode(str('Seller First Name'));
	fieldElement.appendChild(textNode);

	{Append the Seller First Name element to the document element.}
	docElement.appendChild(fieldElement);

	{Create a Seller Last Name element.}
	fieldElement = xmlDoc.createElement("Seller_Last_Name");

	{Create a text node containing data from the Seller Last Name 
	field and append it to the Seller Last Name element.}
	textNode = xmlDoc.createTextNode(str('Seller Last Name'));
	fieldElement.appendChild(textNode);

	{Append the Seller Last Name element to the document element.}
	docElement.appendChild(fieldElement);

	{Create a Phone element.}
	fieldElement = xmlDoc.createElement("Phone");

	{Create a text node containing data from the Phone field and 
	append it to the Phone element.}
	textNode = xmlDoc.createTextNode(str(Phone));
	fieldElement.appendChild(textNode);

	{Append the Phone element to the document element.}
	docElement.appendChild(fieldElement);

	{Save the XML document.}
	xmlDoc.save("C:\RESM\SELLER.XML");
end if;

{Clear the variables.}
clear textNode;
clear fieldElement;
clear docElement;
clear procInstruct;
clear xmlDoc;

The following example uses objects from the Microsoft XML Object Library to parse an XML document and construct a Buyer_Data record in the Real Estate Sales Manager application.

local MSXML.DOMDocument xmlDoc;
local MSXML.IXMLDOMNode rootNode;
local MSXML.IXMLDOMNode dataNode;

{Create an XML document.}
xmlDoc = new MSXML.DOMDocument();

{Load the BUYERS.XML file.}
xmlDoc.load("C:\RESM\BUYERS.XML");

{Retrieve the document’s first child node.}
rootNode = xmlDoc.documentElement;

{Retrieve the 'BuyerID' element and set the 'Buyer ID' field to the text node’s data.}
dataNode = rootNode.selectSingleNode("BuyerID");
'Buyer ID' of table Buyer_Data =  string(dataNode.childNodes.item[0].text);

{Retrieve the 'BuyerFirstName' element and set the 'Buyer First Name' field to the text node’s data.}
dataNode = rootNode.selectSingleNode("BuyerFirstName");
'Buyer First Name' of table Buyer_Data = string(dataNode.childNodes.item[0].text);

{Retrieve the 'Buyer_Last_Name' element and set the 'Buyer Last Name' field to the text node’s data.}
dataNode = rootNode.selectSingleNode("Buyer_Last_Name");
'Buyer Last Name' of table Buyer_Data = string(dataNode.childNodes.item[0].text);

{Retrieve the 'Buyer_Last_Name' element and set the 'Buyer Last Name' field to the text node’s data.}
dataNode = rootNode.selectSingleNode("Buyer_Last_Name");
'Buyer Last Name' of table Buyer_Data = string(dataNode.childNodes.item[0].text);

{Retrieve the 'Agent' element and set the 'Agent' field to the text node’s data.}
dataNode = rootNode.selectSingleNode("Agent");
Agent of table Buyer_Data = string(dataNode.childNodes.item[0].text);

{Save the record, and clear the table buffer.}
save table Buyer_Data;
clear table Buyer_Data;

{Clear the variables.}
clear dataNode;
clear rootNode;
clear xmlDoc;

 


Documentation Feedback