Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 83105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:43:17+00:00 2026-05-10T21:43:17+00:00

I’m trying to search multiple attributes in XML : <APIS> <API Key=00001> <field Username=username1

  • 0

I’m trying to search multiple attributes in XML :

<APIS>   <API Key='00001'>     <field Username='username1' UserPassword='password1' FileName='Filename1.xml'/>     <field Username='username2' UserPassword='password2' FileName='Filename2.xml'/>     <field Username='username3' UserPassword='password3' FileName='Filename3.xml'/>   </API> </APIS> 

I need to check if in the ‘field’ the Username AND UserPassword values are both what I am comparing with my Dataset values, is there a way where I can check multiple attributes (AND condition) without writing my own logic of using Flags and breaking out of loops.

Is there a built in function of XMLDoc that does it? Any help would be appreciated!

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:43:18+00:00Added an answer on May 10, 2026 at 9:43 pm

    To search for what you want in the snippet of XML you provided, you would need the following XPath expression:

    /APIS/API/field[@Username='username1' and @UserPassword='password1'] 

    This would either return something, if user name and password match – or not if they don’t.

    Of couse the XPath expression is just a string – you can build it dynamically with values that were entered into a form field, for example.

    If you tell what language/environment you are in, code samples posted here will likely get more specific.

    This is a way to do it in C# (VB.NET is analogous):

    // make sure the following line is included in your class using System.Xml;  XmlDocument xmldoc = new XmlDocument(); xmldoc.Load('your XML string or file');  string xpath = '/APIS/API/field[@Username='{0}' and @UserPassword='{1}']'; string username = 'username1'; string password = 'password1';  xpath = String.Format(xpath, username, password); XmlNode userNode = xmldoc.SelectSingleNode(xpath);  if (userNode != null) {   // found something with given user name and password } else {   // username or password incorrect } 

    Be aware that neither user names nor passwords can contain single quotes, or the above example will fail. Here is some info on this peculiarity.

    There is also a How-To from Microsoft available: HOW TO: Use the System.Xml.XmlDocument Class to Execute XPath Queries in Visual C# .NET

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.