Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2006

Tip: Looking for answers? Try searching our database.

Jscript variable in XPath expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
j_kowalska@vp.pl - 25 Aug 2006 10:19 GMT
Hi, I'm new to XPath

Could anybody tell me how to use Jscript  variable in XPath expression?

In the folowwing code I get an error ' object required':
...
var selectedCustomer =
XDocument.DOM.selectSingleNode("/my:mojePola/my:Customer").text

var selectedNode =
doc.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Kontakty[@Nazwisko
= selectedCustomer]")
...
when I replace selectedCustomer (in the second line) with a string,
e.g.
...
var selectedNode =
doc.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Kontakty[@Nazwisko
='somestring' ]")
...
everything is OK.

Any hints appreciated,
jpk_2005
S.Y.M. Wong-A-Ton - 25 Aug 2006 11:00 GMT
Your problem might be in another area than where you think it is, but to use
the variable in the expression try this:

var selectedNode =
doc.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Kontakty[@Nazwisko
= '" + selectedCustomer + "']")

If this doesn't solve the error, your problem is probably in one of the
XPAth expressions you have used. The XML nodes are not being found, so you'll
need to debug your XPath expression to find the correct one to the XML nodes
you want to find.
---
S.Y.M. Wong-A-Ton

> Hi, I'm new to XPath
>
[quoted text clipped - 20 lines]
> Any hints appreciated,
> jpk_2005
j_kowalska@vp.pl - 25 Aug 2006 11:42 GMT
Thanks a lot, it solved my problem:)

S.Y.M. Wong-A-Ton napisal(a):
> Your problem might be in another area than where you think it is, but to use
> the variable in the expression try this:
[quoted text clipped - 34 lines]
> > Any hints appreciated,
> > jpk_2005
S.Y.M. Wong-A-Ton - 25 Aug 2006 22:20 GMT
You're welcome. Glad it solved the problem.
---
S.Y.M. Wong-A-Ton

> Thanks a lot, it solved my problem:)
>
[quoted text clipped - 37 lines]
> > > Any hints appreciated,
> > > jpk_2005
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.