473,326 Members | 2,196 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,326 software developers and data experts.

SelectSingleNode..Not Working..???

Hi,
I have an Xml file in which i am storing the usernames and password and
some other user details. The file contains data as shown below..

<?xml version="1.0" encoding="utf-8"?>
<RoleTables xmlns="http://tempuri.org/UserPass.xsd">
<Table>
<username>Arun</username>
<password>jgEEnsYs+ZY=</password>
<Email>ar**@yahoo.com</Email>
</Table>
<Table>
<username>sweta</username>
<password>A/JvqRbKGes=</password>
<Email>si**@ere.com</Email>
</Table>
</RoleTables>

Now I have an aspx page where i am displaying the list of existing
users(which i am getting from this xml file) and displaying as a bound
column of a datagrid and each of these users has a coressponding Edit and
Delete links which are the Hyperlink columns of the DataGrid.

now, My problem is how do i get the corrresponding user information from
this xml file for the userhas been click whose Edit ink ed.
What I have done is in the Hyperlink column attribute i have set
DataNavigateUrlFormatString="AddEditUserAcnts.aspx ?username={0}
And in the PageLoad Event of AddEditUserAcnts.aspx page i am trying to get
to this particular users node.
Please can you tell me how can I get to this particular users node.

I tried using this in my AddEditUserAcnts.aspx page

string userstring = Request.QueryString["username"];

XmlDocument doc = new XmlDocument();
string UserPath = Server.MapPath("UserPass.xml");
doc.Load(UserPath);

XmlNode root = doc.DocumentElement;
XmlNode table = root.SelectSingleNode("descendant::Table[ @user='Arun' ]");

But table always points to null...i.e. I am not able to get to that
particular users node.

Any advice would be helpful...
Thanx
Smita.
Nov 12 '05 #1
2 4387
"smita" <sm***@rarefind.com> wrote
XmlNode table = root.SelectSingleNode("descendant::Table[

@user='Arun' ]");

I'm no XPath expert but i think what you want is:

"descendant::Table[username='Arun']"

I.e., look for the Table whose _child username element_ has a value of
'Arun'.

You were querying for the Table whose _user attribute_ had a value of
'Arun'.
Nov 12 '05 #2
><?xml version="1.0" encoding="utf-8"?>
<RoleTables xmlns="http://tempuri.org/UserPass.xsd">
<Table>
<username>Arun</username>
<password>jgEEnsYs+ZY=</password>
<Email>ar**@yahoo.com</Email>
</Table>
<Table>
<username>sweta</username>
<password>A/JvqRbKGes=</password>
<Email>si**@ere.com</Email>
</Table>
</RoleTables>

XmlNode table = root.SelectSingleNode("descendant::Table[ @user='Arun' ]");

But table always points to null...i.e. I am not able to get to that
particular users node.


Well, the <Table> tag contains a tag called <username> - so maybe you
need to select on that, not on "user" (which doesn't exist). Also, I
think the @user would refer to an attribute "user" of the <Table> tag
- which you don't have - you mostly likely need to use this instead:

XmlNode table =
root.SelectSingleNode("descendant::Table[username='Arun' ]");

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 12 '05 #3

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

Similar topics

1
by: Glenn Venzke | last post by:
I'm trying to invoke the "selectsinglenode" method on an XmlDocument object, but it doesn't seem able to find the node I want. I'm able to access the document root but when I try to parse an...
3
by: John R. | last post by:
I have an application written in C# and i am using MS XML DOM! I have a document with the following structure (only the <DicEntry> - Elements are important): <NewDataSet...
2
by: Edward Yang | last post by:
My XML document has a default namespace specified by xmlns="some_url". Here it is: <?xml version="1.0" encoding="utf-8" ?> <ssmproject name="sample" server="sql"...
7
by: Jason | last post by:
Hi I have an XML file i need to load and read the contents. Here is the top part of the xml file. <Research xsi:schemaLocation="http://www.rixml.org/2002/6/RIXML...
6
by: Jay Bienvenu | last post by:
I have the following Visual Basic .NET code in an ASP.NET project: ' ... Dim xdStructure As XmlDocument Dim xnStructureRoot As XmlNode xdStructure = New XmlDocument...
2
by: adam | last post by:
I tried so many ways to select the node but its not working, please help. I want to research by the identifier in imsmanifest.xml file, the node could be item or resource. XmlDocument doc = new...
7
by: Sashi | last post by:
Two questions: (1) I can pull the text of an XML element as a string just fine using code as such: strSomeString = myXmlDoc.SelectSingleNode("/Element1/Element2/Element3",...
19
by: David Thielen | last post by:
Hi; If there are no namespaces this works fine for me. But if the xml has namespaces, then I get either no node back or an exception. Here is the sample xml: <root xmlns="http://www.test.org"...
0
by: compumate99 | last post by:
I am trying to parse the xml document using selectsinglenode method. I am doing this using Visual Foxpro >>> loResultXml = CreateObject("Microsoft.XMLDOM") With loResultXml .Async = .F. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.