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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:14:10+00:00 2026-06-12T04:14:10+00:00

I have a function where I want to add multiple ‘values’ to a node.

  • 0

I have a function where I want to add multiple ‘values’ to a node. Here is function:

 private void GetCategory(DataRow reader, XmlElement myNode)
    {
        foreach (DataRow categoryRow in reader.GetChildRows("Article_Category"))
        {
            myNode.LastChild.InnerText = categoryRow["CATEGORY_NAME"].ToString();
        }
    }

myNode.OuterXml looks like this:

<field itemid="{2C16342E-7662-432B-9895-5EDB15914D7F}" language="en" version="1" 
fieldid="{1F5956D6-EABE-4F74-A248-B25B7EE90350}" name="Categories" title=""
type="Multilist" source="/sitecore/content/data/Categories" section="Content" 
tooltip=""><value>US</value></field>

I wanted to look something like this:

<field itemid="{2C16342E-7662-432B-9895-5EDB15914D7F}" language="en" version="1" 
fieldid="{1F5956D6-EABE-4F74-A248-B25B7EE90350}" name="Categories" title=""
type="Multilist" source="/sitecore/content/data/Categories" section="Content" 
tooltip=""><value>US</value><value>China</value><value>India</value></field>

I added this function:

 foreach (DataRow categoryRow in reader.GetChildRows("Article_Category"))
        {
            var newNode = myNode.OwnerDocument.CreateElement("Value");
            newNode.InnerText = categoryRow["CATEGORY_NAME"].ToString();
            myNode.AppendChild(newNode);

        }

Its does not work becoz this is how my XML looks like:

 <field itemid="{9259D344-3500-4887-9CDF-F00876F20F2B}" language="en" version="1"
 fieldid="{1F5956D6-EABE-4F74-A248-B25B7EE90350}" name="Country" title="" 
 type="Multilist" source="/sitecore/content/data/Countries" section="Content"
 tooltip=""><value /><Value>Currency Markets</Value></field>

THere is a ‘value’ tag which does not lets add up.

  • 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-12T04:14:12+00:00Added an answer on June 12, 2026 at 4:14 am

    Your current code overwrites the Text of the LastChild. You need to add nodes,

        //untested
        foreach (DataRow categoryRow in reader.GetChildRows("Category"))
        {
          //myNode.LastChild.InnerText = categoryRow["CATEGORY_NAME"].ToString();
    
            var newNode = myNode.OwnerDocument.CreateElement("value");
            newNode.InnerText = categoryRow["CATEGORY_NAME"].ToString();
            myNode.AppendChild(newNode);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an onclick function that I want to add an anchor to the
I have a onclick function like this onclick = function(){alert('hello')} I want to add
I have multiple views defined in my main view. I want to add single
I have two g:select comboboxes that I want to add to the multiple select
I have multiple text boxes with a class name .paymentamount .i want to add
I want to add multiple plugins(which i have created) on a toolbar of ckeditor.
I have one function ParseHtmlTable(string htmlContent) . Now in that function I want to
using .NET 3.5. I have a function I want to make multithreaded calls to.
I have a function that I want to execute on keyup for 2 different
I have a function that i want to pass as a parameter function myFun(){

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.