473,378 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 1536
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.