The elementName parameter in the GetXmlAttribute function now supports a simplified xpath expression to find attribute values in the more complicated structure of CFDiv3.3 XML documents.
Set the elementName argument to the simple name of the element to be found, e.g. "Comprobante" or "cfdi:Comprobante". This will find the first occurence of the element anywhere in the document. To find the Nth element, write as elementName[N] where N is a positive decimal integer (N=1,2,3,...).
For example, "Concepto[3]" will find the third element named Concepto anywhere in the document.
Set elementName as the empty string "" to specify the root element. Set both elementName and attrname to "" to find the name of the root element.
For a more detailed search, specify an xpath expression in the elementName parameter using the child path operator "/" and the descendant operator "//", together with an optional element predicate of the form [N] where N is a positive integer (N=1,2,3,...).
For example, "/Comprobante/Emisor" or "//Concepto[2]//Retencion[3]".
/e1 -- selects the first <e1> document element (child element of the document node)./e1/e2 -- selects the first <e2> child element of the first <e1> document element./e1[2]/e2[3] -- selects the third <e2> child element of the second <e1> document element./e1[1]/e2[1] -- same as /e1/e2.//e2 -- the first <e2> element found anywhere (same as simple e2).//e2[3] -- the third <e2> element found anywhere (same as simple e2[3])./e1//e2 -- the first <e2> element found anywhere inside the <e1> element.
This behaviour is similar to XPath except it selects the first occurrence of the element matching the expression (whereas XPath would select all elements). The elementName xpath expression must begin with a "/" or "//" and must not end with a "/". The expression "//" by itself is not valid. No other XPath function or operator is accepted - including the "@" operator. The required attribute name must be specified separately in the attributeName parameter.
Namespaces are ignored when matching against a path expression. A path element name with prefix - e.g. "/cfdi:Comprobante" - is invalid.
To test for the existence of an element, specify attrname="". This will return the (qualified) name of the element if found, or !NO MATCH! if not found.