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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:20:38+00:00 2026-05-22T21:20:38+00:00

So I am using this code to parse a gigantic (80,000 line) XML document.

  • 0

So I am using this code to parse a gigantic (80,000 line) XML document. However when it was handed to me it added unnessecary rows due to parent nodes(which was fixed by the if statement in the code), and now it is doubling up on empty nodes.

Whenever I hit an empty node it will double up on the node before it… for example here is a peice of the xml:

<edit>
    <who>Jim Johnson(Jim.m.Johnson@google.com)</who>
    <when>2010-08-18T12:14:33.613Z</when>
    <description></description>
</edit>

And the data feed I am getting ends up looking like:

who                Jim Johnson
when               8/18/2010
description        8/18/2010

Anyone have a good idea as to how to trim off those empty tags?
Here is a peice of the code that is generating this table.

using (XmlReader reader = XmlReader.Create(new StringReader(
{
    // Parse the file and display each of the nodes.
    while (reader.Read())
    {
        switch (reader.NodeType)
        {
            case XmlNodeType.Element:
                elementName = reader.Name;
                switch (elementName)
                {
                    //display my title stuff
                }
                break;
            case XmlNodeType.Text:
                elementText = reader.Value;
                break;
            case XmlNodeType.XmlDeclaration:
            case XmlNodeType.ProcessingInstruction:
                break;
            case XmlNodeType.Comment:
                break;
            case XmlNodeType.EndElement:
                if (elementName == reader.Name)
                {
                    contractRowArray1[0] = elementName;
                    contractRowArray1[1] = elementText;
                    contractRow = contractTable.NewRow();
                    contractRow.ItemArray = contractRowArray1;
                    contractTable.Rows.Add(contractRow);
                }
                break;
        }
    }
}
  • 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-22T21:20:39+00:00Added an answer on May 22, 2026 at 9:20 pm

    Does this work?

    case XmlNodeType.Element:
        elementName = reader.Name;
        elementText = null;                  // ADDED
        switch (elementName)
        {
            //display my title stuff
        }
        break;
    

    …

    case XmlNodeType.EndElement:
        if (elementName == reader.Name && elementText != null)       // MODIFIED
        {
            contractRowArray1[0] = elementName;
            contractRowArray1[1] = elementText;
            contractRow = contractTable.NewRow();
            contractRow.ItemArray = contractRowArray1;
            contractTable.Rows.Add(contractRow);
        }
        break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code to parse XML in the instance variable response : @implementation
I have been using this code to parse xml till now. Its was working
I'm trying to parse a html doc using some code I found from this
I am using this code to parse a Date. SimpleDateFormat formatter = new SimpleDateFormat(MM/dd/yyyy);
I'm dealing with an _NSDictionary that I'm trying to parse. I'm using this code
I am using this code to parsing xml DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db
I'm using this code in order to generate XML from my grid's cells values:
i have this xml: <user> <name>H &amp; M</name> and i parse it using this
I am using this code to retreive a html page and parse it while(doc
I am using this code to try and read this XML below, but it

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.