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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:43:34+00:00 2026-06-04T21:43:34+00:00

When i try read my xml file it seems to reads it twice and

  • 0

When i try read my xml file it seems to reads it twice and im unsure on how to fix such an error. I thought i can have some sort of loop but im still lost. Any help would be appreciated ty. – It writes the xml file correctly but the duplicate occurs when it reads it.

String workingDir = Directory.GetCurrentDirectory();
XmlTextReader textReader = new XmlTextReader(workingDir + @"\xmldoc.xml");

Console.WriteLine("BaseURI:" + textReader.BaseURI);
textReader.Read();

while (textReader.Read())
{
    if (textReader.Name == "test")
    {

        textReader.Read();
        XmlNodeType nType = textReader.NodeType;

        if (nType == XmlNodeType.Text)
        {
            //   label.Text = textReader.Value.ToString();
            Label l = new Label();
            System.Drawing.Point l1 = new System.Drawing.Point(15, 13 + a);
            l.Location = l1;
            l.Text = textReader.Value.ToString();

            a += 20;
        }
  • 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-04T21:43:35+00:00Added an answer on June 4, 2026 at 9:43 pm

    What makes you think some entries are read twice? If it is the case, also check if this method is not called twice (shift + F12 in Visual Studio to find usage).
    Also, it seems that the piece of code you joined here is not complete (no declaration of variable ‘a’). Do you have some code executed under the if (textReader.Name == "test") that would do the same operations?

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

Sidebar

Related Questions

I have a javascript function which I try to read XML file. function readXML()
I can read the text file for first time. when i try to read
I try to read an XML file that contains the following element: <ho:CODED-TYPE ho:BASE-DATA-TYPE=A_UINT16
I have some classes that already use DOM4J to read XML files and provide
I have a xml file that changed when i update some values, and i'm
I am getting a 401 unauthorized error when I try to read an XML
When I try to read an XML document (eagle file) with an DTD I
I try to read file /proc/'pid'/status, using c program. The code is as follows,
As a relative newbie I try to read as much as I can about
I try to parse an xml file. The text which is in tags is

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.