I have C # code running on sharepoint which I use to check the infopath document inside the xml to check if I should check the document or discard the document.
The code works fine for several different form templates that I created, but it doesn't work on my latested. I found that the generated XmlNamespaceManager contains an invalid definition for the name "MY".
I will try to explain
I have this code for decoding my XmlNamespaceManager
NameTable nt = new NameTable(); NamespaceManager = new XmlNamespaceManager(nt); // Add prefix/namespace pairs to the XmlNamespaceManager. NamespaceManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); NamespaceManager.AddNamespace("xhtml", "http://www.w3.org/1999/xhtml"); NamespaceManager.AddNamespace("dfs", "http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"); NamespaceManager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-07-14T13:45:59"); NamespaceManager.AddNamespace("xd", "http://schemas.microsoft.com/office/infopath/2003");`
Then I can use the following line of code to search for xml after
XPathNavigator nav = xml.CreateNavigator().SelectSingleNode("//my:HasSaved", NamespaceManager);
nav.Value then gets the data I want.
All of this works fine on several of my form templates. I see a new form template and found that I need to use this line instead
NamespaceManager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-11-30T17:39:37");
The date is different.
My problem is that I cannot add this twice since only one set of forms will work.
So my question. Is there a way that I can generate a NamespaceManager object from an XML file, since all this is contained in the header? I could not find an easy way around this.
source share