PC Review


Reply
 
 
=?Utf-8?B?TFN0YXRpZQ==?=
Guest
Posts: n/a
 
      7th Apr 2005
I am trying to use the following xpath to get nodes that comply with certain
criteria and have tested the xpath using XMLSpy. The xpath also works fine in
the vbscript that showed it as a sample. Using C# however, nothing is
returned since the "<" seems to be causing a problem. Visual Studio .NET 2003
seems to be using xpath 1.0, because using "le" works in XMLSpy but fails in
my code.

Is there any way I can modify the <= or do something to this xpath for it to
work with C#? I tried a @ in front of the variable holding the xpath and that
also failed. I have not been able to find anything anywhere for this case.
Please help.

string xpath = @"//Parent/Child[Completed=1 and Date <= """ + ClaimDate +
"""]";


 
Reply With Quote
 
 
 
 
recoil@community.nospam
Guest
Posts: n/a
 
      7th Apr 2005
try changing the < to a &lt; I would also verify that the resultant
Xpath query is what you expect it to be and that if there are any
namespaces on the xml nodes that you add a Namespace manager
appropriately.

 
Reply With Quote
 
=?Utf-8?B?TFN0YXRpZQ==?=
Guest
Posts: n/a
 
      7th Apr 2005


"(E-Mail Removed)" wrote:

> try changing the < to a < I would also verify that the resultant
> Xpath query is what you expect it to be and that if there are any
> namespaces on the xml nodes that you add a Namespace manager
> appropriately.
>
>

I had previously found information indicating that &llt; would work, but I
get an error that repeats my xpath and appends "has an invalid token", when I
try < or ≤. Just removing the "<", "<" or "≤" will work, but I need to do a
<=, not just an =.
 
Reply With Quote
 
recoil@community.nospam
Guest
Posts: n/a
 
      12th Apr 2005
the expanded logic would be

condition = 1 and ( (date=...) or (date<....))

 
Reply With Quote
 
recoil@community.nospam
Guest
Posts: n/a
 
      14th Apr 2005
String xq = String.Format(
"//downloadmodule[@Architecture=\"{0}\" and @Name=\"{4}\" " +
"and ( version/@Major>{1} or version/@Major={1} " +
" and (version/@Minor > {2} or version/@Minor = {2}" +
"and version/@Build > {3}))]",
Architecture, Major, Minor, Build, Name);
XmlElement nodeUpdate =
(XmlElement)xmlUpdateCfg["updateinfo"].SelectSingleNode(xq);

Works fine for me. If you have specific code that fails then please
a) provide code that is droppable into any project that exhibits this
behavior and often times specifying "how it fails" would also be
helpful.

 
Reply With Quote
 
=?Utf-8?B?TFN0YXRpZQ==?=
Guest
Posts: n/a
 
      14th Apr 2005


"LStatie" wrote:

>
>
> "(E-Mail Removed)" wrote:
>
> > String xq = String.Format(
> > "//downloadmodule[@Architecture=\"{0}\" and @Name=\"{4}\" " +
> > "and ( version/@Major>{1} or version/@Major={1} " +
> > " and (version/@Minor > {2} or version/@Minor = {2}" +
> > "and version/@Build > {3}))]",
> > Architecture, Major, Minor, Build, Name);
> > XmlElement nodeUpdate =
> > (XmlElement)xmlUpdateCfg["updateinfo"].SelectSingleNode(xq);
> >
> > Works fine for me. If you have specific code that fails then please
> > a) provide code that is droppable into any project that exhibits this
> > behavior and often times specifying "how it fails" would also be
> > helpful.
> >
> >

> The code that fails is below:
>
> String xPath = String.Format( "//transactions/transaction[Completed=1 and
> (EffectiveDate < '{0}' and EffectiveDate = '{0}')][last()]", ClaimDate);
>
> XmlElement root = doc.DocumentElement;
> XmlElement node = (XmlElement) root.SelectSingleNode( xPath );
>
> I tried \" instead of ' around {0}.
> I tried XmlNode instead of XmlElement
> I tried @"//transa..." instead of "//transa..."
>
> What keeps happening is that as soon as there is a < or > in the xPath, the
> SelectSingleNode returns null.
>
> P.S. I know that the xml loaded fine and all else works, because all I have
> to do is remove the < from the xPath and I get a node back.


Correction:
String xPath = String.Format( "//transactions/transaction[Completed=1 and
(EffectiveDate < '{0}' or EffectiveDate = '{0}')][last()]", ClaimDate);
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath, XML and other David Microsoft C# .NET 2 25th Nov 2005 12:58 PM
XPath with ADO XML mjwills Microsoft VB .NET 1 24th Oct 2005 08:24 AM
Need XPath help =?Utf-8?B?UmljaGFyZA==?= Microsoft C# .NET 2 4th Oct 2005 09:46 PM
Xpath For Xml Map WStoreyII Microsoft Excel Programming 0 6th Aug 2004 03:11 AM
3rd party xpath for CF (e.g. cuesoft xpath) Yechezkal Gutfreund Microsoft Dot NET Compact Framework 0 6th Nov 2003 01:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:59 PM.