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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:09:39+00:00 2026-06-03T03:09:39+00:00

I have a xml document stored in a file on the server, now i

  • 0

I have a xml document stored in a file on the server, now i want to modify the same using Linq to Xml.
Here is my code:

String strFile = File.ReadAllText(Server.MapPath("~/SessionAnalyserAccessories.xml"));
XDocument xdoc1 = XDocument.Parse(strFile);
xdoc1.XPathSelectElement("SESSIONANALYSER/AP/MODES/NI/STATEINFORMATION/INIT/INPUT/METHOD").AddAfterSelf(new XElement("METHOD", "", new XAttribute("NAME", "Saurabh")));

XML Sample i am using, i need to add an element STATEINFORMATION:

<SESSIONANALYSER>
  <AP>
    <MODES>
      <NI>
        <STATEINFORMATION TYPE="PREPAID">
          <INIT INVALIDINPUTRESPONSE="-2">
            <INPUT VALUE="SLN7ACTIVATION">
              <METHOD NAME="CHECKSUBSCRIBERBALANCE" PARAMETERS="SLN7" POSSIBLEACTIONS="FALLOUTON_FAILUREREGION_SETPSOFAILED_FALSE" MAINTAINSESSION="NO" RESPONSE="-4" NEXTLEVEL="" />
              <METHOD NAME="SETPSOINUCIP" PARAMETERS="SLN7" POSSIBLEACTIONS="FALLOUTON_FAILUREREGION_SETPSOFAILED_FALSE" MAINTAINSESSION="NO" RESPONSE="-4" NEXTLEVEL="" />
            </INPUT>
          </INIT>
        </STATEINFORMATION>
        <STATEINFORMATION TYPE="POSTPAID">
          <INIT INVALIDINPUTRESPONSE="-2">
            <INPUT VALUE="">
              <METHOD NAME="SENDMESSAGE" PARAMETERS="" POSSIBLEACTIONS="FALLOUTONSUCCESS" MAINTAINSESSION="NO" RESPONSE="5" NEXTLEVEL="" />
            </INPUT>
          </INIT>
        </STATEINFORMATION>
      </NI>
    </MODES>
  </AP>
</SESSIONANALYSER>
  • 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-06-03T03:09:40+00:00Added an answer on June 3, 2026 at 3:09 am

    I have found some links which contains samples on adding elements through LINQ in XML tree.

    Please visit these :-

    http://msdn.microsoft.com/en-us/library/bb387083.aspx

    http://msdn.microsoft.com/en-us/library/bb387084.aspx

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

Sidebar

Related Questions

I have an XML document, and I want to print the tag names and
I have this XML document <AdditionalParameters> <PublishToPdf Type =System.Boolean>False</PublishToPdf> </AdditionalParameters> in my code and
I have this XML file here. <?xml version=1.0 encoding=UTF-8?> <xml> <word> <threeletter>RIP</threeletter> <threeletter>PIE</threeletter> <fourletter>PIER</fourletter>
Hey all i have code to write to an xml doc from asp string
I have a process that parses an XML file using JDOM and xpath to
I have the following code where i save the xml file into this particular
I have the following XML Document (that can be redesigned if necessary) that stores
I have an XML document with a default namespace indicated at the root. Something
I have an XML document that I generate from an Entity Framework object. The
I have a XML document with my data in it, multiple entries for the

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.