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

  • Home
  • SEARCH
  • 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 946827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:59:01+00:00 2026-05-15T22:59:01+00:00

This code can’t read a specific attribute – the name attribute more specifically. Instead

  • 0

This code can’t read a specific attribute – the name attribute more specifically.
Instead it read the text of node elements and does a concat on them – result: 1F20 is added to the list

var reader = new StringReader(xml);
            var xmlreader = new XmlTextReader(reader);
            xmlreader.WhitespaceHandling = WhitespaceHandling.None;
            var doc = new XPathDocument(xmlreader);
            var nav = doc.CreateNavigator();
            XPathExpression expr = nav.Compile("/Area/Lights/Light[@Name]");
            XPathNodeIterator iterator = nav.Select(expr);

            var list = new List<string>();
            while (iterator.MoveNext())
            {
                XPathNavigator nav2 = iterator.Current.Clone();
                list.Add(nav2.Value);  
            }

I have also tried:
XPathExpression expr = nav.Compile(“//Light[@Name]”);

which returns blank

This is the xml i am trying to read:

<Light Index="1" SetChannel="72" GetChannel="60" Name="y1 d1">
      <Nodes>1F</Nodes>
      <Nodes>20</Nodes>
    </Light>

What i am doing wrong – first attempt at xpath…

  • 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-15T22:59:02+00:00Added an answer on May 15, 2026 at 10:59 pm

    is this the full XML? using your snippet here this works

    XPathExpression expr = nav.Compile("Light/@Name");
    

    just to add the usage of XPathExpression expr = nav.Compile("/Area/Lights/Light[@Name]"); is a filter, you are asking for a Light node that has an attribute called Name, or you may do something like @Name = 'bob' where you ask for a Light node with an attribute of Name equal to Bob

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

Sidebar

Ask A Question

Stats

  • Questions 502k
  • Answers 502k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer .NET 4.0 can reference .NET 2.0 assemblies, but the reverse… May 16, 2026 at 2:43 pm
  • Editorial Team
    Editorial Team added an answer The problem you're interested in is information extraction from semi… May 16, 2026 at 2:43 pm
  • Editorial Team
    Editorial Team added an answer printf is a powerful function that can do exactely what… May 16, 2026 at 2:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Can anyone explain this code snippet to me? <script type=text/javascript> function querySt(ji) { hu
I have this code and can't figure out what seems to be the problem:
i have this code where you can select the date you like to attend
How can I write this code in one php operator? $menu = theme('nice_menu', 1,
Does anyone know how can I replace this 2 symbol below from the string
In a lot of my PHP classes, I have this code: private $strError =
if you try my code below you can see that the background color is
Say I have a class Code defined like this, with a user specified type
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.