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

  • Home
  • SEARCH
  • 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 6997531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:17:43+00:00 2026-05-27T20:17:43+00:00

I have XML file and the elements/attributes names have : character, how I can

  • 0

I have XML file and the elements/attributes names have “:” character, how I can update its vales?

<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>
<my:ECR my:NoOfAutho="16" my:hideDetails="0" my:Type="ECR" my:NoOfVBUCMApprovales="10" >
    <my:ECRNo>148</my:ECRNo>
    <my:Stage>Approved</my:Stage>
        <my:Details>
        <my:ReasonForCR>Reason For CR</my:ReasonForCR>
        <my:AreaAffected_Publications_VBUCM>false</my:AreaAffected_Publications_VBUCM>
            <my:AreaAffected_Engineering>true</my:AreaAffected_Engineering>
            <my:AreaAffected_Production>false</my:AreaAffected_Production>
            <my:AreaAffected_CustomerSupport>true</my:AreaAffected_CustomerSupport>
            <my:AreaAffected_VBUCMTest>false</my:AreaAffected_VBUCMTest>
        </my:AreaAffectedVB_UCM>
  • 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-27T20:17:44+00:00Added an answer on May 27, 2026 at 8:17 pm

    Your XML sample is invalid as shown. The my prefix is not defined in the XML.

    If your XML contained xmlns:my="schemas.microsoft.com/office/infopath/2003/myXSD/…" then the XML would at least have some hope of being valid.

    For manipulating XML with namespaces in .NET code, consider using Linq XDocument instead of XmlDocument. I have found Linq’s XNamespace and XName types to be much, much easier to use with the XDocument family of classes than the old style XmlDocument‘s rather clunky handling of namespaces.

    Change your XML to add the xmlns:my attribute to the root element:

    <my:MNO xmlns:my="schemas.microsoft.com/office/infopath/2003/myXSD/…" my:NoOfAutho="16" etc... >
    

    In your C# code, add a reference to the Linq stuff to the top of your source file:

    using System.Xml.Linq;
    

    Then use code like this (not checked, may contain syntax typos) to load the xml and access the element:

    XNamespace ns = "schemas.microsoft.com/office/infopath/2003/myXSD/…";
    XName MNO_Name = ns + "MNO";
    XDocument doc = XDocument.Load(path2);
    XElement MNO_Element = doc.Root.Descendants(MNO_Name).Single();
    

    You can then read or modify the properties, attributes, and children of the MNO element.

    To read the value of <MNO>100</MNO>, use MNO_Element.Value.

    To write a new value to the element, assign to the value property: MNO_Element.Value = "120";

    .Single() asserts that there is exactly one node that matches the selection criteria, similar to the .SelectSingleNode() function of XmlDocument.

    As you can see from this code, the name of the “my” namespace prefix in the XML document is immaterial to the code that processes the XML – it’s the URI that the “my” prefix represents that is what is important. The prefix is just shorthand so the the XML writer doesn’t have to write long and laborious URIs everywhere.

    Writing your XML processing code to be agnostic of the XML namespace prefix is very important because the prefix name can (and will) vary from one XML doc to the next, but the namespace URI will be the same.

    • 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 formatted like this: <?xml version=1.0 encoding=utf-8?> <Snippets> <Snippet name=abc>
I have this XML file: <?xml version=1.0 encoding=UTF-8 standalone=no?> <games> <game id=123456 name=501> <player
I have the following XML file: <?xml version=1.0 encoding=utf-8 ?> <strategies> <strategy name=God Class>
Do developers have to put certain/extra elements in the feed's XML file or attributes
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an XML Schema Definition file .XSD who's elements are in Spanish. I
I have an xml file that contains its element like <ab:test>Str</ab:test> When I am
I have an xml file which describes (among other things) elements with attribute values
I have a small XML file: <wddxPacket version='1.0'> <header/> <data> <struct type='coldfusion.runtime.ArgumentCollection'> <var name='HEADLINE'>
I have this XML file: <Elements> <Element name=A.B.C.x> <Child>...</Child> <Child>...</Child> <Child>...</Child> </Element> <Element name=A.B.C.y>

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.