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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:54:38+00:00 2026-05-23T07:54:38+00:00

I have the following .xml file: <?xml version=1.0 encoding=utf-8 ?> <Params> <Name>Resolver1</Name> <RemoteHosts> <Host>

  • 0

I have the following .xml file:

<?xml version="1.0" encoding="utf-8" ?>
<Params>
  <Name>Resolver1</Name>
  <RemoteHosts>
    <Host>
      <Name>Locale</Name>
       <IP>localhost</IP>
       <Port>8082</Port>
     </Host>
  </RemoteHosts>
</Params>

Now, when I try to add another “Host” in the “RemoteHosts” section using the following code it raises a NullReferenceException:

XDocument xmlList = XDocument.Load("NetConfig.xml");

xmlList.Element("RemoteHosts").Add(new XElement("Host",    
new XElement("Name", h.name),
new XElement("IP", h.IP),
new XElement("Port", h.port)));

anyway the

xmlList.Save("NetConfig.xml");

works well, saving the new item…what’s wrong?

  • 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-23T07:54:39+00:00Added an answer on May 23, 2026 at 7:54 am

    XmlList contains only 1 node and its Params not RemoteHosts

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

Sidebar

Related Questions

I have created the following vsct file xml. <?xml version=1.0 encoding=utf-8?> <CommandTable xmlns=http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable xmlns:xs=http://www.w3.org/2001/XMLSchema>
I have the following xml file: <?xml version=1.0 encoding=UTF-8 standalone=no ?> <config> <a> <b>
I have the following file Log4net.config in my bin directory: <?xml version=1.0 encoding=utf-8 ?>
lets say i have the following XML <?xml version=1.0 encoding=utf-8?> <names> <name first=John last=Doe/>
I have the following main.xml file with a LinearLayout <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have the following XML file: <?xml version=1.0 encoding=utf-8?> <SearchResults:searchresults xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.zillow.com/static/xsd/SearchResults.xsd /vstatic/279989c5e93d519f8d8f23d3f6cac661/static/xsd/SearchResults.xsd xmlns:SearchResults=http://www.zillow.com/static/xsd/SearchResults.xsd>
I have the following xml file: <?xml version=1.0 encoding=utf-8?> <root> <phrase id=test><![CDATA[test]]></phrase> <phrase id=test0><![CDATA[test0]]></phrase>
I have the following XML from a .NET web service: <?xml version=1.0 encoding=utf-8?> <DataSet>
I have the following text in xml file: <Config Builder=LP Wizard> <Libraries> <Library Name=XCAMSource/>
I have the following xml file: <xfa:data> <form1> <Page1> <Page2> <contractInfo> ... </contractInfo> <paymentInfo>

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.