XML.SetAttribute

XML.SetAttribute (

string XMLPath,

string AttributeName,

string AttributeValue )

Example 1

-- This example assumes the sample XML is already loaded into memory.

-- Return the currently loaded XML in a string.
strXML = XML.GetXML();

if (strXML ~= "") then
Dialog.Message("Original XML contents",strXML);
end

-- Changes the second customer element's attribute id to "9999".
XML.SetAttribute("database/customer:2", "id", "9999");

-- See if any errors occurred. If no errors occurred, display the string.
error = Application.GetLastError();
if (error == 0) then
-- Return the currently loaded (modified) XML in a string.
strXML = XML.GetXML();
if (strXML ~= "") then
Dialog.Message("Modified XML contents",strXML);
end
else
Dialog.Message("Error", _tblErrorMessages[error]);
end

Gets the currently loaded XML as a string and shows it in a dialog message. Next, the second customer element's attribute id is changed to "9999" and the new XML is shown in a dialog message.

See also: Related Actions