PBDOM Element.GetChildElement(name) returns null

Symptom

It cannot get the element object using the Element.GetChildElement(name) method. But you can get this element in a loop using the GetChildElements method.

PB GetChildElements syntax:

pbdom_element_name.GetChildElements(ref pbdom_element pbdom_element_array)

PB GetChildElement syntax:

pbdom_element_name.GetChildElement(string strElementName)

Cause

The parent element has a default namespace in the actual XML file. So the method to get the child element required more than one parameter in the GetChildElement method. Therefore, due to interference of the default namespace, it cannot get the element object.

https://www.quackit.com/xml/tutorial/xml_default_namespace.cfm

Solution

Use the overloaded method pbdom_element_name.GetChildElement(string strElementName, string strNamespacePrefix, string strNamespaceUri).

Here is the modified code:

////here's where the problem is
//lpbdom_elem_addr = lpbdom_elem_addr_scrol.GetChildElement("VENDOR_ADDR")
//IF IsNull(lpbdom_elem_addr) THEN
//MessageBox("Error", "GetChildElement returns null for VENDOR_ADDR")
//END IF
lpbdom_elem_addr = lpbdom_elem_addr_scrol.GetChildElement("VENDOR_ADDR","","http://xmlns.oracle.com/Enterprise/Tools/schemas/M798354.V1")