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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:46:51+00:00 2026-05-16T23:46:51+00:00

Coding Platform: ASP.NET C# I have an XML like this. <Items> <Map id=35> <Terrains>

  • 0

Coding Platform: ASP.NET C#

I have an XML like this.

<Items>
    <Map id="35">
        <Terrains>
            <Item id="1" row="0" column="0"/>
            <Item id="1" row="0" column="1"/>
            <Item id="1" row="0" column="2"/>
            <Item id="1" row="0" column="3"/>
            <Item id="1" row="0" column="4"/>
        </Terrains>
    </Map>
</Items>

I would like to minify this to

<Its>
    <Map id="30">
        <Te>
            <It id="1" r="0" c="0"/>
            <It id="1" r="0" c="1"/>
            <It id="1" r="0" c="2"/>
            <It id="1" r="0" c="3"/>
            <It id="1" r="0" c="4"/>
        </Te>
    </Map>
</Its>

Then I am converting this to JSON using James Newton-King’s JSON Converter.
The idea is to minify the xml data to the maximum as it contains tens of thousands of lines.

My questions are

  1. What is the optimal method to minify the xml as mentioned above?
  2. Now its done like XML-MinifyXML-Convert to JSON. Can I do it in two steps?(XML-Minify while converting to JSON)
  3. Is James Newton-King’s JSON converter a bit overkill for this simple conversion?

Please provide code snippets also if possible.

  • 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-16T23:46:52+00:00Added an answer on May 16, 2026 at 11:46 pm

    I suspect GZIP (via GZipStream, or simply via IIS, noting that you need to enable dynamic compression for the json mime-type) would be both simpler and smaller, but if you are using serializarion, simply adding some [XmlElement(…)] / [XmlAttribute(…)] should do it. Of course, if size is your concern, can I also suggest something like protobuf-net, which gives an extremely dense binary output.

    If you aren’t using serialisation, then this looks an ideal fit for some “xslt”:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="@* | node()">
        <xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy>
      </xsl:template>
      <xsl:template match="/Items">
        <Its><xsl:apply-templates/></Its>
      </xsl:template>
      <xsl:template match="/Items/Map/Terrains">
        <Te><xsl:apply-templates/></Te>
      </xsl:template>
      <xsl:template match="/Items/Map/Terrains/Item">
        <It id="{@id}" r="{@row}" c="{@column}"><xsl:apply-templates select="*"/></It>
      </xsl:template>
    </xsl:stylesheet>
    

    (with C#:)

    XslCompiledTransform xslt = new XslCompiledTransform();
    xslt.Load("Condense.xslt"); // cache and re-use this object; don't Load each time
    xslt.Transform("Data.xml", "Smaller.xml");
    
     Console.WriteLine("{0} vs {1}",
        new FileInfo("Data.xml").Length,
        new FileInfo("Smaller.xml").Length);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coding Platform ASP.NET 4.0 WebForms I have two pages that are relevant here Login.aspx
Coding Platform: ASP.NET 4.0 WebForms with C# We have a website with the existing
Coding Platform: ASP.NET C# Controls Used: asp:Wizard and asp:Button I have a asp:Wizard and
Coding Platform ASP.NET 4.0 WebForms on IIS7.5 If I request a page blahblah.aspx which
Coding Platform: ASP.NET WebForms4.0 VB Installed Facebook and FacebookWeb and when I run the
Coding Platform: ASP.NET 4.0 C# Consider the following scenario. I am uploading a file
I'm coding in C++/MFC on a Windows platform (using MS VS2008.) I have this
I am coding for iOs. I would like to interact with a webservices platform
I've been coding for a while now and would like to start looking into
was hoping if anyone could help. I would like to be able to have

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.