472,960 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,960 software developers and data experts.

filtering nodes containiing qname valuies using xpath

hi, while playing with the SAML specs I found that one must insert a node like this if the call succeded

<status xmlns:z=mynamspace" ...

<z:statuscode result="z:Sucess"/>

...

How do I set up an XPATH filter that veriffies if the call succeed ? .. I mean i cannot hardcode z:Success since another one could pass me out a doc like this

<x xmlns:k=mynamspace" ...

<k:statuscode result="k:Sucess"/>

...

The code I wrote is something like what you see below .. however I wonder if there is a way to make xpath aware of namepsace while evaluating elements and attributes text ..

I mean, what an XSd parser does when meets type="xsd:string" ?

string s = "<a xmlns:k='abcd' ><b k:aa='k:success'></b></a>";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument ();
doc.LoadXml (s);
XmlNamespaceManager ns = new XmlNamespaceManager (doc.NameTable );
ns.AddNamespace ("xx","abcd");
string dd = "//@xx:aa[.='" + doc.DocumentElement.GetPrefixOfNamespace("abcd") + ":success']";
XmlNode x = doc.SelectSingleNode (dd,ns);
System.Diagnostics.Debug.WriteLine ( x.InnerText );

suggestions are welcome
--
Enrico Sabbadin
Mail: sa******@sabbasoft.com
Website: http://www.sabbasoft.com
********
MTS - COM+ - VBCOM - Enterprise Services - Security FAQ
..NET & COM+ books selected list
********
Blog: http://www.sabbasoft.com/myblog

Affiliated Sites
http://www.vb2themax.com
http://www.codearchitects.com
Nov 12 '05 #1
1 1528
enrico sabbadin @ infinito wrote:
hi, while playing with the SAML specs I found that one must insert a
node like this if the call succeded

<status xmlns:z=mynamspace" ...

<z:statuscode result="z:Sucess"/>

How do I set up an XPATH filter that veriffies if the call succeed ? ..
I mean i cannot hardcode z:Success since another one could pass me out a
doc like this

<x xmlns:k=mynamspace" ...

<k:statuscode result="k:Sucess"/>

The code I wrote is something like what you see below .. however I
wonder if there is a way to make xpath aware of namepsace while
evaluating elements and attributes text ..


Yeah, but not in a strughtforward way. Something like:

//@result[
substring-after(., ':')='Sucess' and
name(../namespace::*[.='mynamspace'])=substring-before(., ':')
]

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

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

Similar topics

4
by: elora_c | last post by:
I'm trying to write XSLT that will filter out an XML based on an attribute's value. XML looks like: <postings> <channel name="A"> <posting Connected="True" name="Posting1" /> <posting...
3
by: serge calderara | last post by:
Dear all, I have a csv file data which has been read and populate on a dataset object. then I need to bind part of the content of the dataset to a treeview control. I have read that XML format...
2
by: Felicity | last post by:
Hello, Using the following XML file, I would like to be able to filter using an XPath to the nodes where Menu = Yes and Form Name = frmMainMenu <?xml version="1.0" standalone="yes"?>...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
5
by: David Thielen | last post by:
Hi; I set up my xml as follows: XmlDocument xml = new XmlDocument(); xml.Load(File.Open("data.xml", FileMode.Open, FileAccess.Read)); XmlNamespaceManager context = new...
6
by: Paul J Lay | last post by:
I am using the XmlDocument Select Nodes method and it seems to work OK except that it returns embedded nodes in the collection when I only want the nodes that are not embedded. For example I have...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
1
by: Arndt Jonasson | last post by:
The definition of XPath 1.0 says "A QName in the node test is expanded into an expanded-name using the namespace declarations from the expression context. This is the same way expansion is done...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.