How to use XPath in Infopath XML correctly? (C#, .NET 2.0)

G

Guest

I have an infopath XML file and want to use XPath queries with the
XmlDocument object. The Problem: Every (in my eyes correct) XPath query does
return a NULL object.

Example:
XmlDocument doc = new XmlDocument();
doc.Load(fileName);

XmlNamespaceManager nsmgr = new
XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("my",
"http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-06-15T14:06:41");

String Name = doc.SelectSingleNode("/my:myFields/my:edName",
nsmgr).InnerText;
System.Windows.Forms.MessageBox.Show(Name);

In fileName there is the correct file name of my infopath xml document.
Iterating through all nodes from doc.DocumentElement through all childnodes
does work, so the file is loaded correctly.

doc.SelectSingleNode does return a null reference. Why?

I use this Document:

<?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution solutionVersion="1.0.0.72" productVersion="12.0.0"
PIVersion="1.0.0.0"
href="file:///C:\Dokumente%20und%20Einstellungen\UserName\Desktop\GWP\Mein%20Stundenachweis.xsn"
name="urn:schemas-microsoft-com:blush:ffice:infopath:Mein-Stundenachweis:-myXSD-2006-02-09T21-22-41" ?>
<?mso-application progid="InfoPath.Document"?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-09T21:22:41"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="de">
<my:edName>Sebastian Gingter</my:edName>
<my:edJahr>2006</my:edJahr>
<my:edMonat>09</my:edMonat>
<my:edKW>36</my:edKW>
<my:timeEntries>
<my:timeEntry>
<my:dtArbeitstag>2006-09-04</my:dtArbeitstag>
<my:startTime>17:00:00</my:startTime>
<my:endTime>18:00:00</my:endTime>
<my:edAuftragsnummer>123456</my:edAuftragsnummer>
<my:startBreakTime>17:15:00</my:startBreakTime>
<my:endBreakTime>17:30:00</my:endBreakTime>
<my:memoTaetigkeit>TEST</my:memoTaetigkeit>
<my:lookIBN>X</my:lookIBN>
<my:lookTaetigkeit>IT-SW</my:lookTaetigkeit>
<my:totalHours>0.75</my:totalHours>
</my:timeEntry>
<!-- some more timeEntries... -->
<my:grandTotal>0.75</my:grandTotal>
</my:timeEntries>
</my:myFields>

Thanks in advance, Sebastian
 
Top