Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 11th, 2005, 10:50 PM
Steve B. [Labo.Net]
Guest
 
Posts: n/a
Default XPath pb

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 DOM.xml property
:

<?xml version="1.0" ?>

<?mso-infoPathSolution productVersion=\"11.0.5329\" PIVersion=\"1.0.0.0\"
href=\"file:///C:\Documents%20and%20Settings\t-stevbe\Local%20Settings\Appli
cation%20Data\Microsoft\InfoPath\7ab6e8af39fc42e2\ manifest.xsf\"
solutionVersion=\"1.0.0.9\" initialView=\"messagesList\" ?>

<?mso-application progid=\"InfoPath.Document\"?>

<dfs:myFields
xmlns:my="\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2003-07-
24T09:51:34\"

xmlns:s1="\"http://microsoft.com/wsdl/types/\"
xmlns:s0="\"http://tempuri.org/\"
xmlns:dfs="\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolut
ion\"

xml:lang="\"fr\">

<dfs:queryFields>

<s0:GetMessagesByUserName>

<s0:userName>EUROPE\t-stevbe</s0:userName>

</s0:GetMessagesByUserName>

</dfs:queryFields>

<dfs:dataFields>

<GetMessagesByUserNameResponse xmlns="\"http://tempuri.org/\">

<GetMessagesByUserNameResult />

<messages>

<Message>

<UserName>DOMAIN\user</UserName>

<EMail>user@domain.com</EMail>

<MessageTitle>Test</MessageTitle>

<MessageBody>etettete</MessageBody>

<MessageID>bd3d5156-3960-4074-a7f8-f75d35e61219</MessageID>

<MessageDate>2003-07-21T15:52:11.8770000+02:00</MessageDate>

</Message>

</messages>

</GetMessagesByUserNameResponse>

</dfs:dataFields>

</dfs:myFields>



Is the XPath expression correct ??

Note that the expression "//dfs:dataFields" return actually the right node,
but the expression "//dfs:dataFields/GetMessagesByUserNameResponse" return 0
items.



Thanks for any help !



Steve


  #2  
Old November 11th, 2005, 10:50 PM
Oleg Tkachenko
Guest
 
Posts: n/a
Default Re: XPath pb

Steve B. [Labo.Net] wrote:

[color=blue]
> In infopath, I use a XPath expression to get some nodes :
>
> var oEMailNodeList = XDocument.DOM.selectNodes("//Message/EMail");[/color]

[color=blue]
> <GetMessagesByUserNameResponse xmlns="\"http://tempuri.org/\">
>
> <GetMessagesByUserNameResult />
>
> <messages>
>
> <Message>[/color]

[color=blue]
> Is the XPath expression correct ??[/color]
Nope. See yourself - Message element is in "http://tempuri.org/" namespace,
while //Message expression selects Message elements in null namespace.
Read about namespace issues in selectNodes method documentation.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles