Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

XMLDocumentComponent

Updated on October 19, 2022

Use the xmlDocumentComponent to manipulate an XML document in your automation. Adding an xmlDocumentComponent to an automation is synonymous to creating an instance of an XML document.

Using the xmlDocumentComponent methods, you can load a document and then modify it by inserting nodes, modifying nodes, and deleting nodes. You can associate the xmlDocumentComponent with a schema. When associated with a schema, Studio provides properties and methods to enforce the document structure while manipulating the document within automations.

A subsidiary component to the xmlDocumentComponent is the xmlElementComponent. The xmlElementComponent represents an individual XML element within an XML document. The xmlElementComponent provides the basis for all element manipulations within an XML document and is also used as a base type when generating data types from an XML Schema Definition (XSD) to provide enhanced XML manipulation capabilities around various data types defined within an XSD. The xmlElementComponent is not a toolbox-resident component; it is accessed from the xmlDocumentComponent to get instances of this type when navigating through or adding elements to a document.

When you add the XMLDocumentComponent to an automation, the system places it in the Globals folder. This component must be global to be referenced by other automations in the project.

These xmlDocumentComponent functions are available for the component:

  • SaveDiagnostics
  • Refresh (accessed from the Edit Schema Provider)
  • Edit Schema Provider
  • Clear (accessed from the Edit Schema Provider)
  • View Schema

These functions only apply when using the xmlDocumentComponent in StonglyTyped DocumentMode, such as when using a schema.

Note: When you add the xmlDocumentComponent to an automation, it is placed in the Globals folder, which allows access to the document to any automation in the solution.

The following table describes the Properties available in the XMLDocumentComponent.

Properties

PropertyDescriptionType
ChildNodesGets a list of child nodes from the designated XML document. IList <xmlElementComponent>
DocumentGets the xmlDocumentComponent for a document. xmlDocumentComponent
DocumentElementGets the document element as an xmlElementComponent. xmlElementComponent
DocumentMode

Gets the current document mode. The options are:

  • FreeForm – No schema provider
  • StronglyTyped – Using a schema provider. For more information, see xmlDocumentComponent with Schema.

The default mode is FreeForm. After selecting a schema using the Set Schema Provider link, the mode is automatically set to StronglyTyped.

xmlDocumentMode
HasChildNodesReturns True if the document has child nodes. Boolean
InnerTextGets or sets the concatenated values of the document and all its child nodes. Note that you cannot use this property to set the values in a strongly typed document. String
InnerXMLGets or sets the markup for the children of the document. Note that you cannot use this property to set the values in a strongly typed document. String
LocalNameGets the local name of the document. String
NodeNameGets the qualified name of the node. String
OuterXML Gets the full text of document. String
PrefixGets the namespace for the prefix. String
SchemaProviderGets the schema provider assigned to the document, if any. xmlSchemaProvider
ValidGets the last know validation state. Boolean
ValidationErrorsGets a list of validation errors from last execution of the Validate method. xmlDocumentValidation[]

The following table describes the available methods for the XMLDocumentComponent, including the parameters and return type for each:

Methods

MethodDescriptionParametersReturn Type
AppendChildFor this node, adds the specified node to the end of the list of child nodes.newChild XmlNodeXmlNode
AppendChildFor this node, adds the specified node to the end of the list of child nodes.newChild XmlNodeXmlNode
ClearDocumentClears a document element to a blank state.NoneVoid
GetAttributeGets the value of an attribute on the root element.StringString
GetDocumentGets the xmlDocumentComponent to which this node belongs. xmlDocumentComponent documentBoolean
GetDocumentElementReturns the document element. NonexmlElementComponent or descendent type
GetFirstChild Gets the first child node of the document. Returns True if element output is not null. NonexmlElementComponent element, Boolean
GetLastChildGets the last child node of the document. Returns True if element output is not null. NonexmlElementComponent element, Boolean
GetNextSiblingGets the node immediately following this node.NonexmlElementComponent, Boolean
GetParentNode Gets the parent of this node (for nodes that have parents).NonexmlElementComponent, Boolean
GetPreviousSiblingGets the node immediately preceding this node.NonexmlElementComponent, Boolean
InsertInserts the specified node as a child of this node at the given index. Returns True if the insert is successful.Integer Index, String XML Boolean
InsertInserts a child of the node at a given index. The document's index must be zero. Returns True if the insert is successful.Integer Index, xmlElementComponent element Boolean
InsertAfterInserts an element after the node selected by the xPath. Returns True if the insert is successful.String Xpath, String XML Boolean
Inserts an element after the node selected by the xPath. Returns True if the insert is successful.String Xpath, xmlElementComponent Element Boolean
InsertBeforeInserts an element before the selected node. Node selection via the XPath. Returns True if the insert is successful. String Xpath, String XML Boolean
InsertBeforeInserts an element before the selected node. Node selection via the XPath. Returns True if the insert is successful. String Xpath, xmlElementComponent Element Boolean
LoadLoads XML into the document from the file you specified. Returns True if the document load is successful. String Filename Boolean
LoadLoads XML into the document from the stream. Returns True if the document load is successful. Stream Stream Boolean
LoadXMLLoads XML into the document from the string. Returns True if the document load is successful. String XMLBoolean
PrependChildPrepends XML to the document element. String XML Void
PrependChildPrepends element to the document element. xmlElementComponent Element Void
RemoveRemoves the immediate child of the node at the given index. For elements that do not support indexing, the index value is ignored. Int Integer Void
RemoveNodesRemoves the nodes as specified by the XPath. Returns True if the nodes are located and removed. String Xpath Boolean
RemoveSingleNodeRemoves the first node selected by XPath. Returns True if the node is located and removed. String Xpath Boolean
ReplaceReplaces the node selected by XPath with the XML you specified. Returns True if the node is located and replaced. String Xpath, String XML Boolean
ReplaceReplaces node selected by XPath with the specified element. Returns True if the node is located and replaced. String Xpath, xmlElementComponent Element Boolean
SaveSaves current document. Returns True if the save is successful. NoneBoolean
SaveSaves document to specified file. Returns True if the save is successful. String Filename Boolean
SaveSaves document to specified stream. Returns True if the save is successful. Stream Stream Boolean
SelectNodesSelects the nodes by specified XPath and returns a list of xmlElementComponents. String Xpath IList xmlElementComponents
SelectSingleNode Selects the first node matching the XPath. String Xpath xmlElementComponent
ToStringReturns OuterXML value. NoneString
ValidateValidates the document against the associated schema provider. This method only applies to strongly typed documents.NoneBoolean
ValidateValidates the document against the XSD set in the xsdFilePath property. This method only applies to strongly typed documents. String xsdFilePath Boolean
ViewDocumentDisplays a modal dialog that contains a web browser that shows the current contents of the XML document. NoneVoid
ViewSchemaDisplays a modal dialog that contains a web browser that shows the current contents of the document schema (.xsd file). NoneVoid
ViewSchemaDisplays a modal dialog that contains a web browser that shows the current contents of the XSD set in the xsdFilePath property. String xsdFilePath Void

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us