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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:31:20+00:00 2026-05-26T12:31:20+00:00

I am using XmlDocument and XmlNode to manipulate a xml file. Say I want

  • 0

I am using XmlDocument and XmlNode to manipulate a xml file. Say I want to add a valid node called “Language” to the root, I use such code:

Dim languageNode As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Language", Nothing)
languageNode.InnerText = "en-US"
root.AppendChild(languageNode)

where xmlDoc is a XmlDocument object and has already been loaded. However, in the xml file after the operation, it appeas like this:

<Language xmlns="">en-US</Language>

And this doesn’t pass the validation. Is there anyway to get rid of the namespace? Thanks!

Update:
I am editing a .rdlc file, which defines a local report, and using xml format. Part of the file looks like this:

<?xml version="1.0" encoding="utf-16"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" 
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

<Language xmlns="">en-US</Language>
...

Normally there shouldn’t be so many namespaces in use but I am generating it from xslt. But the Language node is added after this file is generated. My code looks like this:

Dim xmlRdlc As New XmlDocument()
xmlRdlc.Load(file)    
Dim root As XmlNode = xmlRdlc.DocumentElement()
Dim languageNode As XmlNode = xmlRdlc.CreateNode(XmlNodeType.Element, "Language", Nothing)
languageNode.InnerText = "en-US"
root.AppendChild(languageNode)
xmlRdlc.Save(file)

So how should I do to add the desired node like this:

<Language>en-US</Language>
  • 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-26T12:31:21+00:00Added an answer on May 26, 2026 at 12:31 pm

    You need to specify the namespace. Pass “http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition” as the last parameter to the method.

    Dim xmlRdlc As New XmlDocument()
    xmlRdlc.Load(file)    
    Dim root As XmlNode = xmlRdlc.DocumentElement()
    Dim languageNode As XmlNode = xmlRdlc.CreateNode(XmlNodeType.Element, "Language", _
        "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition")
    languageNode.InnerText = "en-US"
    root.AppendChild(languageNode)
    xmlRdlc.Save(file)
    

    BTW, this would be cleaner using LINQ to XML:

    Dim rdlcNS As XNamespace = "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"
    Dim xmlRdlc = XDocument.Load(file)
    xmlRdlc.Root.Add(New XElement(rdlcNS + "Language", "en-US"))
    xmlRdlc.Save(file)
    

    (translation to VB.NET approximate, your mileage may vary, etc.)

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

Sidebar

Related Questions

Using C# How do you remove a specific node from an XMLDocument using XPATH?
I am using an XmlDocument to parse and manipulate an XHTML string, converting some
I have parsed XML using both of the following two methods... Parsing the XmlDocument
I've referenced System.Xml: using System.Xml; Then in this line: XmlDocument xdoc = new XmlDocument();
So I'm trying to parse the following XML document with C#, using System.XML: <root
Is it possible to create children using XmlDocument.CreateElement() and XmlNode.AppendChild() without specifying the namespace
i've an xml file like <Root> <Steps> <Step Test=SampleTestOne Status=Fail /> <Step Test=SampleTestTwo Status=Fail
I am using the following code to retrieve data from the xml file. It
I have a very simple xml string that I loaded using XmlDocument class. Now
I am trying to parse somewhat standard XML documents that use a schema called

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.