473,803 Members | 2,279 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 4576
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
1422
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
1494
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
15513
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
9699
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
10309
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
10289
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
10068
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
9119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
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...
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.