473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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\Deskto p\GWP\Mein%20Stundenachweis.xsn"
name="urn:schemas-microsoft-com:office: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
Sep 11 '06 #1
0 3924

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sven Steinacker | last post by:
Hi, XSLT files generated by Microsoft InfoPath applied to an applicable XML file produces quite decent HTML presentations. At least with Mozilla and, of course, IE 6.0 the results look the same...
1
by: Steve B. [Labo.Net] | last post by:
Hi In infopath, I use a XPath expression to get some nodes : var oEMailNodeList = XDocument.DOM.selectNodes("//Message/EMail"); My problem is that this method returns 0 items. Here is the...
0
by: Pascal Brunot | last post by:
Hi, Running XSDObjectGen (1.4.1.0) on the following Infopath-generated XSD gives an "unexpected error": "Event register full" during generation (exact english error message may differ, i am...
4
by: MJ | last post by:
A question for InfoPath and ASP.NET experts: What do you think about the future of InfoPath and ASP.NET WebForms? Is InfoPath 12 going to replace ASP.NET WebForms? If not, in which types of...
0
by: Cosimo Galasso | last post by:
I'm building a aspx web page with a button control. When the button is clicked the server build an xml string containg the directive to be opened with infopath. When the client receive the file an...
3
by: Jeff Richardson | last post by:
This is a repost from the InfoPath news group. Hi, I am writing a SharePoint application that works with InfoPath forms. When a user submits a completed InfoPath form to a forms library my code...
0
by: =?Utf-8?B?Q2hhcmxlcyBTaW1wc29u?= | last post by:
Hello I've tried in the InfoPath groups but no luck yet. Here is my situation: All computers are on an Active Directory domain in the company. I have an Infopath form stored on the network...
0
by: Anni | last post by:
Hi, Can anyone please tell me how do I give same namespace for different infopath forms.? I have an XML formed by an infopath form, the XML is : <?mso-infoPathSolution...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.