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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:56:35+00:00 2026-05-23T10:56:35+00:00

Question I have a XML schema as this which i need to append more

  • 0

Question

I have a XML schema as this which i need to append more product to this file , i was trying XMLdocument and Xdocument both classes but didnt got any good results

<prodcuts>
  <product>
    <name>123</name>
    <price>123</price>
  </product>
</products>

CODE:

i was trying Xdocument class with this code

        XDocument xmldoc = XDocument.Load("F://products.xml");
        XElement parentElement = new XElement(xmldoc.XPathSelectElement("product"));
        XElement newElement = new XElement("name","32323");
        XElement newElement = new XElement("price","150");
        parentElement.Add(newElement);
        xmldoc.Save("F://products.xml");

Exception

Value cannot be null.
Parameter name: other

I was tring XMLdocument class too but no results…

Where am i wrong ? … is this problem can solved in LINQ or any other method ?

  • 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-23T10:56:36+00:00Added an answer on May 23, 2026 at 10:56 am

    This will create a new XElement under the Root node which is where I think you want it.

    xmlDoc.Root.Add(
        new XElement("product",
            new XElement("name", "456"),
            new XElement("price", "456")));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file format that contains a structure of questions: <question id=q101>
We have a question with regards to XML-sig and need detail about the optional
I have an XML file containing seed data that I'm trying to load into
I'm currently configuring my schema.xml file and trying to figure out what's the best
I'm working with a complicated xml schema, for which I have created a class
I'm an XML Schema noob, and this is my first Stack Overflow question. Please
I have an XSD (XML Schema) which contains multiple files. There's a catalog.xml in
My question is the following. I have xml that is versioned by a namespace.
Question We have a large number of xml configuration files that we want merged
So, i have some question about xml Documents in Java. Can i get all

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.