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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:04:26+00:00 2026-06-03T04:04:26+00:00

This is my script, but it only prints spaces in the console. Can someone

  • 0

This is my script, but it only prints spaces in the console. Can someone explain how I can get the attribute values from a XML file using xPath?

    XPathNavigator nav;
    XPathDocument docNav;
    XPathNodeIterator NodeIter;
    XmlNamespaceManager ns;

    Int32 elementCount;

    String windowName;

    private void Form1_Load(object sender, EventArgs e)
    {
        docNav = new XPathDocument("C:/BlueEyeMacro/DaMaGeX/Applications/WindowBuilder/GUI.xml");
        nav = docNav.CreateNavigator();
        ns = new XmlNamespaceManager(nav.NameTable); 
        elementCount = nav.Select("/GUI/window").Count;
        Console.WriteLine(elementCount);
        for (int i = 1; i <= elementCount; i++)
        {
            NodeIter = nav.Select("/GUI/window[@ID="+i+"]");
            windowName = NodeIter.Current.GetAttribute("name", ns.DefaultNamespace);
            Console.WriteLine("{0}", windowName);
        }
    }
}

XML File
<GUI>
<window ID="1" name="mainWindow" parent="0" type="0" text="My first window" options="Option 1;" actions="action 1;" exit="exit;" />
<window ID="2" name="secondWindow" parent="0" type="0" text="My second window" options="Option 1;" actions="action 1;" exit="exit;" />
<window ID="3" name="thirdWindow" parent="0" type="0" text="My third window" options="Option 1;" actions="action 1;" exit="exit;" />
</GUI>

  • 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-06-03T04:04:28+00:00Added an answer on June 3, 2026 at 4:04 am

    I guess, you have to call NodeIter.MoveNext() first like in this code:

    XPathNodeIterator nodesText = nodesNavigator.SelectDescendants(XPathNodeType.Text, false);
    
    while (nodesText.MoveNext())
    {
        Console.Write(nodesText.Current.Name);
        Console.WriteLine(nodesText.Current.Value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I swear this script worked fine last night but can't get it to work
I use this script: $(document).ready(function() { $page = jQuery.url.attr(file); alert(page); }); but I get
I want to get this image uploading script right, but for whatever reason it
I'm trying to get this simple PowerShell script working, but I think something is
I copied this script from internet but idon't know how to use it. i
Whenever I run this script the find part executes but the if statement causes
I'm writing this script to rotate a background Image every 3 seconds but it
I have this script that works, but I need to change the format of
I'm using this script to display all the images in a folder, but I
I have a question about this script I found and used. It works but

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.