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 932511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:40:51+00:00 2026-05-15T20:40:51+00:00

I am trying to search an xml element from the root element of the

  • 0

I am trying to search an xml element from the root element of the file on the basis of inner text. i have tried this but didnt work:

rootElRecDocXml.SelectSingleNode("/ArrayOfRecentFiles[name='"+mFilePath+"']");

I know the old school way to traverse all file element by element but i dont want to do that.

Please note that: my root element name is ArrayOfRecentFiles and my child element name are RecentFile

  • 1 1 Answer
  • 0 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. Editorial Team
    Editorial Team
    2026-05-15T20:40:51+00:00Added an answer on May 15, 2026 at 8:40 pm

    We’d need to see the xml; @Lee gives the correct approach here, so something like:

    var el = rootElRecDocXml.SelectSingleNode(
              "/ArrayOfRecentFiles/RecentFile[text()='"+mFilePath+"']");
    

    (taking your edit/reply into account)

    However! There are lots of gotchas:

    • the query will be case-sensitive
    • white-space will be significant (so <foo>abc</foo> is different to <foo> abc[newline]</foo> etc – ditto carriage return)
    • xml namespaces are significant, so you may need .SelectSingleNode("/alias:ArrayOfRecentFiles[text()='"+mFilePath+"']", nsmgr);, where nsmgr is the namespace-manager

    To give a complete example, that matches your comment:

    XmlDocument rootElRecDocXml = new XmlDocument();
    rootElRecDocXml.LoadXml(@"<ArrayOfRecentFiles> <RecentFile>C:\asd\1\Examples\8389.atc</RecentFile> <RecentFile>C:\asd\1\Examples\8385.atc</RecentFile>   </ArrayOfRecentFiles>");
    string mFilePath = @"C:\asd\1\Examples\8385.atc";
    var el = rootElRecDocXml.SelectSingleNode(
        "/ArrayOfRecentFiles/RecentFile[text()='" + mFilePath + "']");
    

    Here, el is not null after the SelectSingleNode call. It finds the node.

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

Sidebar

Related Questions

I am trying to extract values from an XML file using linq to create
I'm trying to search multiple attributes in XML : <APIS> <API Key=00001> <field Username=username1
I'm trying to highlight the search results but I want to include the surrounding
I'm trying to use Live Search 2.0 but even a simple example doesn't seem
I'm trying to open/load an XML file specified in an Excel worksheet in the
im trying to get the integer value from the following xml structure (its only
im trying to use libxml2.2 to parse an XML file in my iPhone app
I'm trying to search using the windows search one of my web directories for
I'm trying to implement search result highlighting for pdfs in a web app. I
I'm trying to get a case-insensitive search with two strings in JavaScript working. Normally

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.