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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:03:51+00:00 2026-05-11T03:03:51+00:00

We were given a sample document, and need to be able to reproduce the

  • 0

We were given a sample document, and need to be able to reproduce the structure of the document exactly for a vendor. However, I’m a little lost with how C# handles namespaces. Here’s a sample of the document:

<?xml version='1.0' encoding='UTF-8'?> <Doc1 xmlns='http://www.sample.com/file' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'    xsi:schemaLocation='http://www.sample.com/file/long/path.xsd'>     <header>         <stuff>data</stuff>         <morestuff>data</morestuff>     </header>  </Doc1> 

How I’d usually go about this is to load a blank document, and then start populating it:

XmlDocument doc = new XmlDocument(); doc.LoadXml('<Doc1></Doc1>'); // Add nodes here with insert, etc... 

Once I get the document started, how do I get the namespace and schema into the Doc1 element? If I start with the namespace and schema in the Doc1 element by including them in the LoadXml(), then all of the child elements have the namespace on them — and that’s a no-no. The document is rejected.

So in other words, I have to produce it EXACTLY as shown. (And I’d rather not just write text-to-a-file in C# and hope it’s valid XML).

  • 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. 2026-05-11T03:03:52+00:00Added an answer on May 11, 2026 at 3:03 am

    You should try it that way

      XmlDocument doc = new XmlDocument();      XmlSchema schema = new XmlSchema();   schema.Namespaces.Add('xmlns', 'http://www.sample.com/file');    doc.Schemas.Add(schema); 

    Do not forget to include the following namespaces:

    using System.Xml.Schema; using System.Xml; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 101k
  • Answers 101k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The first thing you are doing wrong is trying to… May 11, 2026 at 8:00 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure if this is the fasted code in… May 11, 2026 at 8:00 pm
  • Editorial Team
    Editorial Team added an answer Anything that is abstractable to an extendable root upon which… May 11, 2026 at 8:00 pm

Related Questions

Yes, I realize this question was asked and answered, but I have specific questions
Given a function, I'm trying to find out the names of the nested functions
At my place of work I've been put in charge of creating a coding
I've created a custom workflow which creates a task item when the workflow is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.