Problem adding namespaces to MSXML (using setProperty('SelectionNamespaces', ...))

Posted by conciliator on Stack Overflow See other posts from Stack Overflow or by conciliator
Published on 2010-04-03T19:30:57Z Indexed on 2010/04/03 19:33 UTC
Read the original article Hit count: 1023

Filed under:
|

A while back, I asked a question regarding the usage of namespaces in MSXML. At first, I circumvented the whole thing with the XPath *[local-name()]-hack (see my previous post), but having a crisis of conscience I decided to do things the right way. (Doh!)

Consider the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<Root xsi:schemaLocation="http://www.foo.bar mySchema.xsd" xmlns="http://www.foo.bar" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <MyElement>
  </MyElement>
</Root>

When I try to add these namespaces using IXMLDOMDocument3.setProperty('SelectionNamespaces', NSString);, I get the following error: "SelectionNamespaces property value is invalid. Only well-formed xmlns attributes are allowed.". When removing the namespace xsi:schemaLocation="http://www.foo.bar mySchema.xsd", everything runs smoothly. What am I doing wrong here? Is there an error in the XML? Is MSXML to blame?

© Stack Overflow or respective owner

Related posts about msxml

Related posts about namespaces