473,789 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it possible to use regular expressions inside of an xpath statement executed by System.Xml.XmlD ocument.SelectS ingleNode() ?

Is it possible to use regular expressions inside of an xpath statement
executed by System.Xml.XmlD ocument.SelectS ingleNode() ?

string sdoc = "<foo><bar a='1'/><bar a='2'/></foo>";
System.Xml.XmlD ocument pdoc = new System.Xml.XmlD ocument();
pdoc.LoadXml(sd oc);
System.Xml.XmlN ode pnode =
pdoc.SelectSing leNode("//foo/bar/matches(.,'\\d' )");
string foo = pnode.InnerText ;
int i23 = 23 + 23;
May 24 '06 #1
4 4575
Daniel wrote:
Is it possible to use regular expressions inside of an xpath statement
executed by System.Xml.XmlD ocument.SelectS ingleNode() ?

string sdoc = "<foo><bar a='1'/><bar a='2'/></foo>";
System.Xml.XmlD ocument pdoc = new System.Xml.XmlD ocument();
pdoc.LoadXml(sd oc);
System.Xml.XmlN ode pnode =
pdoc.SelectSing leNode("//foo/bar/matches(.,'\\d' )");
string foo = pnode.InnerText ;
int i23 = 23 + 23;


Yes, when using EXSLT.NET. See
http://msdn.microsoft.com/xml/defaul...ctexslt_topic4

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
May 24 '06 #2
Daniel wrote:
Is it possible to use regular expressions inside of an xpath statement
executed by System.Xml.XmlD ocument.SelectS ingleNode() ?

string sdoc = "<foo><bar a='1'/><bar a='2'/></foo>";
System.Xml.XmlD ocument pdoc = new System.Xml.XmlD ocument();
pdoc.LoadXml(sd oc);
System.Xml.XmlN ode pnode =
pdoc.SelectSing leNode("//foo/bar/matches(.,'\\d' )");
string foo = pnode.InnerText ;
int i23 = 23 + 23;


Forgot to mention that latest EXSLT.NET version can found at
http://www.xmlmvp.org/exslt.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
May 24 '06 #3
EXSLT.NET has nothing to support regular expressions inside of xpath for
System.Xml.XmlN ode xpath methods such as SelectNodes or SelectSingleNod e

http://msdn.microsoft.com/xml/defaul...ctexslt_topic4
"Oleg Tkachenko [MVP]" <so**@body.co m> wrote in message
news:Of******** ******@TK2MSFTN GP03.phx.gbl...
Daniel wrote:
Is it possible to use regular expressions inside of an xpath statement
executed by System.Xml.XmlD ocument.SelectS ingleNode() ?

string sdoc = "<foo><bar a='1'/><bar a='2'/></foo>";
System.Xml.XmlD ocument pdoc = new System.Xml.XmlD ocument();
pdoc.LoadXml(sd oc);
System.Xml.XmlN ode pnode =
pdoc.SelectSing leNode("//foo/bar/matches(.,'\\d' )");
string foo = pnode.InnerText ;
int i23 = 23 + 23;


Yes, when using EXSLT.NET. See
http://msdn.microsoft.com/xml/defaul...ctexslt_topic4

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com

May 25 '06 #4
Daniel wrote:
EXSLT.NET has nothing to support regular expressions inside of xpath for
System.Xml.XmlN ode xpath methods such as SelectNodes or SelectSingleNod e


These methods are just wrappers around XPathNavigator. Select() method
and you are right, they are useless with EXSLT.NET. Use XPathNavigator
instead. Here is a sample how to use EXSLT function with XmlDocument and
XPath.

XmlDocument doc = new XmlDocument();
doc.Load("foo.x ml");
XPathNavigator nav = doc.CreateNavig ator();
XPathExpression expr = nav.Compile("se t:distinct(//@country)");
expr.SetContext (new ExsltContext(do c.NameTable));
XPathNodeIterat or ni = nav.Select(expr );
while (ni.MoveNext()) {
Console.WriteLi ne(ni.Current.V alue);
}

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
May 25 '06 #5

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

Similar topics

5
471
by: John Bailo | last post by:
I wrote a webservice to output a report file. The fields of the report are formatted based on information in an in-memory XmlDocument. As each row of a SqlDataReader are looped through, a lookup is done, and format information retrieved. The performance was extremely poor -- producing about 1000 rows per minute. However, when I used tracing/logging, my results were inconclusive. First of all, based on the size of the data and the...
4
5843
by: Andreas Håkansson | last post by:
I have a price of XML that looks like this <Root> <SomeNode> ..... </SomeNode> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> ... </Signature> </Root>
7
5498
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned that an xpath expression can be bounded by either single or double quotation marks. But sometimes I want to search for a title containing both a single and double quote. Any way to do this?
3
1420
by: Shawn | last post by:
Hi. I have an XML file that looks like this: <?xml version="1.0" encoding="utf-16"?> <Transfer> <Config xmlns="http://www.mysite.com/Transfer/"> <site>NY</site> </Config> </Transfer> I'm trying to get the value of "site", but I'm having some trouble with it.
2
1492
by: J Mon | last post by:
I have a XML document with elements like <offer> <field name="name"><!]></field> <field name="merchant_id"><!]></field> ..... </offer> I know not the best XML! Now I am selecting different values by XPath having an XmlNode representing the <offer> element. Now when I try something like this
6
15511
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
5
2167
by: Chua Wen Ching | last post by:
Hi, I read from this tutorial at codeproject Question A: http://www.codeproject.com/csharp/GsXPathTutorial.asp regarding xpath.. but i try to apply in my situation, and can't get it work...
2
3483
by: probashi | last post by:
Hi, >From the sample xml, I am trying to select a book and then select the author of the select book. In the example code first SelectSingleNode selects a book. Second SelectSingleNode on the book node should return the author of the selected book (???). But I am getting the first author in the document (Margaret Atwood), not the author of the selected book (Jane Austen).
1
1293
by: Daniel | last post by:
Is it possible to use regular expressions inside of an xpath statement executed by System.Xml.XmlDocument.SelectSingleNode() ? string sdoc = "<foo><bar a='1'/><bar a='2'/></foo>"; System.Xml.XmlDocument pdoc = new System.Xml.XmlDocument(); pdoc.LoadXml(sdoc); System.Xml.XmlNode pnode = pdoc.SelectSingleNode("//foo/bar/matches(.,'\\d')"); string foo = pnode.InnerText; int i23 = 23 + 23;
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.