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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:53:08+00:00 2026-05-13T20:53:08+00:00

I am trying to create an XML file to conform to someones XSD this

  • 0

I am trying to create an XML file to conform to someones XSD this XSD allows for XHTML content within its description tag. I have cut short the method hierarchy but basically it does the following:

using System.Xml.Linq;

public static XDocument Create()
    {            
        XDocument doc = new XDocument(
          new XDeclaration("1.0", Encoding.UTF8.HeaderName, String.Empty),
            GetCourses()
            );

        //ValidatingProcess(@".\xcri_cap_1_1.xsd", doc.ToString());

        return doc;
    }

private static XElement GetCourses(XElement provider)
    {
        //datatbale dt generated here from sql
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            provider.Add(new XElement("course",
                  new XElement("identifier", dt.Rows[i]["QN_ID"]),
                  new XElement("title", dt.Rows[i]["LSC Descriptor"]),
                  new XElement("subject", dt.Rows[i]["category"]),
                  new XElement("description", dt.Rows[i]["Course_Overview"],
                    new XAttribute("Type", "Course Overview")),
                  //new XElement("description", dt.Rows[i]["Entry_Requirements"]),
                    //new XAttribute("Type", "Entry Requirements"),
                  new XElement("description", dt.Rows[i]["Course_Contents"],
                    new XAttribute("Type", "Course Contents")),
                  new XElement("description", dt.Rows[i]["Assessment"],
                    new XAttribute("Type", "Assessment")),
                  new XElement("description", dt.Rows[i]["Progression_Route"],
                    new XAttribute("Type", "Progression Route")),
                  new XElement("url", "http://www.nnc.ac.uk/CourseLeaflets/Leaflet2.aspx?qnid=" + dt.Rows[i]["QN_ID"]),
                    GetQualification(dt.Rows[i])//,
                    //GetPresentation(row)
                    ));
        }

        return provider;
    }

The fields like “Course_Overview”, “Entry_Requirements” contain XHTML without URL encoding but when added to the XDocument it seems to automatically encode them so I end up with &lt;P&gt; instead of <P>. Is there anyway to stop this or am I going to have to use something instead of XDocument.

The reason I started with XDocument is the layout of the code can appear similar to the end result.

  • 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-13T20:53:08+00:00Added an answer on May 13, 2026 at 8:53 pm

    Adding text content is treated as if you wanted text content, and not “inner XML”.

    I think you would be best converting the string of XML into a Document Fragment, and then adding that fragment (essentially the sring needs to be converted into nodes, and then add the nodes).

    Use XElement.Parse to create the document fragment.

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

Sidebar

Related Questions

I am trying to create an XSD schema file from an existing XML file
I'm trying to create an XML file to conform to Indeed.com's Job Listing XML.
I am trying to create a dynamically generated XML file from Java. This is
I am trying to create an XML file, but the XML file needs to
I'm trying to create an xml entry that looks like this using python and
I'm trying to create an element in an XML where the basic content is
I am trying to create an XSD schema which will validate the following xml.
In relation to this previous question I am trying to create a batch file
I am trying to create a Xml schema for a xml file that looks
I am learning XML and I am trying to create a XML file for

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.