InfoPath IXMLDOMDocument: Reference to undeclared namespace prefixOctober 30, 2007 12:00
Trying to set a query property in the DOM of a data source I received the error “Reference to undeclared namespace prefix: ‘tns’”. The reason of this error is that the xml contains multiple namespaces and that you have to explicitly define the namespace to use. By default the DOM property you can access from the XDocument are of the type IXMLDOMDocument. But working with this type, does not allow you to set the required namespace for your selections. To get around the issue convert the IXMLDOMDocument to a IXMLDOMDocument2 which makes it possible to define a “SelectionNamespaces” property. If you fill this property with the required documentElement’s namespace, the xpath selection of your node will succeed and the error is gone. Below is an example of the Data source’s IXMLDOMDocument2 content (xml) and some demo code to select the required node. Tags: data source, Infopath, interop, IXMLDOMDocument, namespace prefix, node, xml. |
||