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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:09:44+00:00 2026-05-13T23:09:44+00:00

I want to write my xml with following format. How can i do it?I

  • 0

I want to write my xml with following format. How can i do it?I am using c#

<map borderColor='c5e5b8' fillColor='6a9057' numberSuffix=' Mill.' includeValueInLabels='0' labelSepChar=': ' baseFontSize='9' showFCMenuItem='0'
hoverColor='c2bc23' showTitle='0' type='0' showCanvasBorder='0' bgAlpha='0,0' hoveronEmpty='1' includeNameInLabels='0' showLabels='1'>
<!--toolText='Alaska'imageSave='1' imageSaveURL='Path/FusionChartsSave.aspx or FusionChartsSave.php'-->
<data>
<entity id='AL' value='AL' link="JavaScript:FilterClientProjectList('AL');" fontBold='1' showLabel='0' />
<entity id='AK' value='AK' link="JavaScript:FilterClientProjectList('AK');" fontBold='1' hoverColor='6a9057'/>
<entity id='AZ' value='AZ' link="JavaScript:FilterClientProjectList('AZ');" fontBold='1'/>
</data>

<styles>
<definition>
<style name='MyFirstFontStyle' type='font' face='Verdana' size='11' color='0372AB' bold='1' bgColor='FFFFFF' />
</definition>
<application>
 <apply toObject='Labels' styles='' />
</application>
</styles>
</map>

Thanks in advance..

  • 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-13T23:09:44+00:00Added an answer on May 13, 2026 at 11:09 pm

    I would use LINQ to SQL(mydatasource assumed SQL) then LINQ to XML then XSLT to get the exact XML you are looking for.

    Here is an example:
    My XML

    <Promotions> 
          <Promotion> 
            <Category>Arts &amp; Entertainment</Category> 
            <Client>Client 1</Client> 
            <ID>2</ID> 
            <Title>Get your Free 2</Title> 
          </Promotion> 
          <Promotion> 
            <Category>Community &amp; Neighborhood</Category> 
            <Client>Client1</Client> 
            <ID>4</ID> 
            <Title>Get your Free 4</Title> 
          </Promotion> 
          <Promotion> 
            <Category>Community &amp; Neighborhood</Category> 
            <Client>Client 1</Client> 
            <ID>5</ID> 
            <Title>Get your Free 5</Title> 
          </Promotion> 
          <Promotion> 
            <Category>Community &amp; Neighborhood</Category> 
            <Client>Client 2</Client> 
            <ID>1</ID> 
            <Title>Get your Free 1</Title> 
          </Promotion> 
          <Promotion> 
            <Category>Education</Category> 
            <Client>Client 3</Client> 
            <ID>3</ID> 
            <Title>Get Your Free 3</Title> 
          </Promotion> 
          <Promotion> 
            <Category>Home &amp; Garden</Category> 
            <Client>Client 4</Client> 
            <ID>6</ID> 
            <Title>Get your Free 6</Title> 
          </Promotion> 
        </Promotions> 
    

    My code:

     PromotionsDataContext db = new PromotionsDataContext();
                            //load sql into XML for tree view js control
                            XElement Categories =
                                new XElement("Promotions",
                                    from b in db.Promotion_GetPromotions()
                                    select new XElement("Promotion",
                                        new XElement("Category", b.CategoryName),
                                           new XElement("Client", b.ClientName),
                                           new XElement("ID", b.ID),
                                           new XElement("Title", b.Title)));
    
                            XDocument mydoc = new XDocument();
                            mydoc.Add(Categories);
    
                            try
                            {
    
                            // Load the style sheet.
                            XslCompiledTransform xslt = new XslCompiledTransform();
                            xslt.Load(@"C:\TransList.xslt");
    
                            // Execute the transform and output the results to a writer.
                            StringWriter sw = new StringWriter();
                            //XsltSettings mysettings = new XsltSettings();
                            XmlWriterSettings mysettings = new XmlWriterSettings();
    
                            xslt.Transform(mydoc.CreateReader(), null, sw);
    

    My XSLT file:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="http://schemas.microsoft.com/ASPNET/20">
    
    
      <xsl:output method="html" indent="yes" />
    
      <xsl:key name="categories" match="Category" use="." />
      <xsl:key name="client" match="Client" use="." />
      <xsl:key name="title" match="Title" use="." />
    
      <xsl:template match="/">
    
        <ul id="red" class="treeview-red">
          <xsl:for-each select="/Promotions/Promotion/Category[  
                    generate-id(.) = generate-id(key('categories', .)[1])  
                    ]">
            <li>
              <span>
                <xsl:value-of select="."/>
                <!--Category-->
              </span>
    
              <ul>
                <xsl:call-template name="category-client">
                  <xsl:with-param name="category" select="."/>
                  <!--Client-->
                </xsl:call-template>
              </ul>
            </li>
    
          </xsl:for-each>
        </ul>
    
      </xsl:template>
    
      <xsl:template name="category-client">
        <xsl:param name="category" />
        <xsl:for-each select="/Promotions/Promotion[Category=$category]/Client[  
                    generate-id(.) = generate-id(key('client', .)[1]) 
                    ]">
          <li>
            <span>
              <xsl:value-of select="."/>
            </span>
            <ul>
              <xsl:call-template name="category-client-title">
                <xsl:with-param name="category" select="$category"/>
                <!--Title-->
                <xsl:with-param name="client" select="."/>
              </xsl:call-template>
            </ul>
          </li>
        </xsl:for-each>
      </xsl:template>
    
      <xsl:template name="category-client-title">
        <xsl:param name="category" />
        <xsl:param name="client" />
        <xsl:for-each select="/Promotions/Promotion[Category=$category]/Title[  
                    generate-id(.) = generate-id(key('title', .)[1]) 
                    ]">
          <li>
            <span>
              <asp:LinkButton ID ="LinkButton{../ID}" runat="server" OnClick="LinkClicked" Text="{.}">
              </asp:LinkButton>
            </span>
          </li>
    
        </xsl:for-each>
    
      </xsl:template>
    
    </xsl:stylesheet>
    

    Here are some things I found when working with XSLT in C#:

    What am I doing wrong here, having issues with XSLT using C#

    How do I retrieve a sibling by tag name in XSLT?

    XSLT renders &gt; and &lt; for >< how to do I get around this?

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

Sidebar

Related Questions

The following string gets encoded in my source XML using toggles, and I want
I need to generate an XML file in C#. I want to write the
I want to read an xml file, apply a transform, then write to another
I want to write a little DBQuery function in perl so I can have
I want to write a stored procedure that queries XML files after I have
I want to write an xslt to transform one xml file to another. The
I want to write a Swing application in Griffon but I am not sure
I want to write a command that specifies the word under the cursor in
I want to write a function in Python that returns different fixed values based
I want to write a function that takes an array of letters as an

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.