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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:25:05+00:00 2026-05-14T16:25:05+00:00

my problem is the following: How can I remove selected ChildNodes from XmlNode recursively?

  • 0

my problem is the following:
How can I remove selected ChildNodes from XmlNode recursively? My XML-file looks like…

..<element type="TextBox" id="xslFilePath">
                <parameters>
                    <parameter id="description">
                        <value><![CDATA[Pfad zur XSL]]></value>
                        <value lang="en"><![CDATA[XSL-file's path]]></value>
                    </parameter>
                    <parameter id="tooltip">
                        <value><![CDATA[Pfad zur XSL]]></value>
                        <value lang="en"><![CDATA[XSL-file's path]]></value>
                    </parameter>
                </parameters>
                <values>
                    <value><![CDATA[/include/extensions/languageReferences/xsl/default.xsl]]></value>
                </values>
            </element>
            <element type="DropDownList" id="imageOrientation">
                <parameters>
                    <parameter id="description">
                        <value><![CDATA[Anordnung]]></value>
                        <value lang="en"><![CDATA[Orientation]]></value>
                    </parameter>
                    <parameter id="tooltip">
                        <value><![CDATA[Anordnung]]></value>
                        <value lang="en"><![CDATA[Orientation]]></value>
                    </parameter>
                </parameters>
                <items>
                    <item id="" selected="true">
                        <parameters>
                            <parameter id="value">
                                <value><![CDATA[vertical]]></value>
                            </parameter>
                            <parameter id="description">
                                <value><![CDATA[senkrecht]]></value>
                                <value lang="en"><![CDATA[vertical]]></value>
                            </parameter>
                        </parameters>
                    </item>
                    <item id="" selected="false">
                        <parameters>
                            <parameter id="value">
                                <value><![CDATA[horizontal]]></value>
                            </parameter>
                            <parameter id="description">
                                <value><![CDATA[waagerecht]]></value>
                                <value lang="en"><![CDATA[horizontal]]></value>
                            </parameter>
                        </parameters>
                    </item>
                </items>
                <values>
                    <value><![CDATA[horizontal]]></value>
                </values>
            </element>...

I would like to remove all nodes (type of value) where the parentNode is type of parameter with id=”description” but not value-notes as children of values or parameter with id=”value” In XSLT I would say e.g.: //value[parent::parameter[@id='description'] and @lang='en']The problem is: I have the language code: e.g. “de” and now I would like to remove all sibling value nodes if an value with lang=”de” exists and remove all sibling nodes excluding the value without any lang-attribute if lang=”de” not exists (as fallback) I hope, you can help me to write an c# Code to replace recursively all undesired value-nodes.

  • 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-14T16:25:05+00:00Added an answer on May 14, 2026 at 4:25 pm

    Hopefully this is what you´r looking for.

    If you load you´r xml into a XmlDocument you can use a method like this one to remove nodes matching an xpath.

    public void RemoveElements(XmlDocument document, string xpathForElementsToRemove)
    {
        if (document == null || document.DocumentElement == null) return;
        var xmlNodeList = document.DocumentElement.SelectNodes(xpathForElementsToRemove);
        if (xmlNodeList == null || xmlNodeList.Count == 0) return;
        for (var n = xmlNodeList.Count - 1; n >= 0; n--)
        {
            var xmlNode = xmlNodeList[n];
            if (xmlNode.ParentNode == null) continue;
            xmlNode.ParentNode.RemoveChild(xmlNode);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I fix the following problem with IE6/7(IE Tester) with drop-down list(with fixed
Who can help me to fix the following problem? Here is the issue: in
I have the following problem: I have a search box in which user can
I have the following problem: I have an Activity where a user can start
I can't for the life of me figure out the following problem (I'm not
I have the following problem. I am making this website you can see in
My problem can be reduced to basically the following set of entities : I
Consider following code: My problem is: 1) I can't seem to cast the errors
The following is 2 different definitions of the problem: How can I process 2
it is the problem, i can't undertand anyway. i have the following simple script

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.