IT Process Automation

CA PAM::. How to read a XML file - applyXPath Function 

Jan 27, 2017 01:07 PM

applyXPath Function - CA Process Automation - 4.2.2 - CA Technologies Documentation 

 

 

Syntax / Sintaxe

sXML = applyXPath(xmlDataxpathQuerynamespaceAwarereturnArray)

Arguments

xmlData (String)

Defines the XML on which to run the XPath query.

Define o XML no qual executar a consulta XPath.

xpathQuery (String)

Defines the XPath query to run.

Define a consulta XPath a ser executada.

namespaceAware (Boolean)

(Optional) Specifies whether to strip name spaces before applying the XPath query.

(Opcional) Especifica se deseja remover espaços de nome antes de aplicar a consulta XPath

Values:

True:CA Process Automation does not strip name spaces before applying the XPath query. / o CA Process Automation não remove espaços de nome antes de aplicar a consulta XPath.
False: CA Process Automation strips name spaces before applying the XPath query, making the query simple.  /  o CA Process Automation remove espaços de nome antes de aplicar a consulta XPath, tornando a consulta simples.

Default: True

returnArray (Boolean)

(Optional) Specifies whether to return an array of results or a single string.  /  (Opcional) Especifica se deve retornar ma matriz de resultados ou uma única sequência de caracteres.

Values:

True: The function returns an array of results.   /  a função retorna uma matriz de resultados.
False: The function returns a single string with multiple results concatenated in the string.  /  a função retorna uma única sequência de caracteres com vários resultados concatenados na sequência de caracteres.

Default: False

If the XPath query does not find a match, it returns a blank array.   /   Se a consulta XPath não encontrar uma correspondência, retornará uma matriz vazia.

Return Values and Examples

One of the following return values, based on the value of the returnArray argument.   /   Um dos seguintes valores de retorno, com base no valor do argumento returnArray.

  • When returnArray is false:   /   Quando returnArray for falso:

sXML (String)
If you omit the returnArray argument or you set it to false, the query returns this value. The value that returns is an XML fragment that lists the nodes. For example:

Se você omitir esse argumento returnArray ou defini-lo como false, a consulta retornará esse valor. O valor retornado é um fragmento XML que lista os nós. Por exemplo:

Process.xpathResult = applyXPath(Process.bookXML, "/bookstore/book[2]", true, false);

  • When returnArray is true:  /  Quando returnArray for verdadeiro:

sXMLArray (C2OValueArray)
If you set the returnArray argument to true, the query returns this value. The value that returns is a C2OValueArray in which each element is an XML fragment for a node. For example:

Se você definir o argumento returnArray como true, a consulta retornará esse valor. O valor que é retornado é uma C2OValueArray na qual cada elemento é um fragmento XML de um nó. Por exemplo:

Process.xpathArrayResult = applyXPath(Process.bookXML, "/bookstore/book", true, true);

EXAMPLE

<?xml version="1.0" encoding="UTF-8"?><UDSObjectList>
<UDSObject>
<Handle>prp:400219</Handle>
<Attributes>
<Attribute DataType="2001">
<AttrName>sequence</AttrName>
<AttrValue>11</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>label</AttrName>
<AttrValue>Load?</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>value</AttrName>
<AttrValue>Yes</AttrValue>
</Attribute>
</Attributes>
</UDSObject>
<UDSObject>
<Handle>prp:400220</Handle>
<Attributes>
<Attribute DataType="2001">
<AttrName>sequence</AttrName>
<AttrValue>15</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>label</AttrName>
<AttrValue>Company Number</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>value</AttrName>
<AttrValue>1234567</AttrValue>
</Attribute>
</Attributes>
</UDSObject>
<UDSObject>
<Handle>prp:400221</Handle>
<Attributes>
<Attribute DataType="2001">
<AttrName>sequence</AttrName>
<AttrValue>20</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>label</AttrName>
<AttrValue>Quantity</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>value</AttrName>
<AttrValue>3</AttrValue>
</Attribute>
</Attributes>
</UDSObject>
<UDSObject>
<Handle>prp:400222</Handle>
<Attributes>
<Attribute DataType="2001">
<AttrName>sequence</AttrName>
<AttrValue>30</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>label</AttrName>
<AttrValue>Configuration Item.</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>value</AttrName>
<AttrValue>XYZ</AttrValue>
</Attribute>
</Attributes>
</UDSObject>
</UDSObjectList>

 

Process.xpathArrayResult2 = applyXPath(Process.XMLPRP, "//Attributes/Attribute/AttrName/text()", true, true);

Process.xpathArrayResult3 = applyXPath(Process.XMLPRP, "//Attributes/Attribute/AttrValue/text()", true, true);

 

Statistics
0 Favorited
4 Views
0 Files
0 Shares
0 Downloads

Related Entries and Links

No Related Resource entered.