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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:08:58+00:00 2026-06-16T05:08:58+00:00

Help for values ​​in a xml at various levels. This is the xml: <widgets>

  • 0

Help for values ​​in a xml at various levels.

This is the xml:

<widgets>
    <id>95</id>

    <widget type="1" name="accventas" caption="Ofertas ventas" flags="4">
        <service name="pm_venofer_total00001" caption="Pendientes de aceptar" desc="" type="3" detail="1">
            <xvalue>20</xvalue>
            <xcolor>1</xcolor>
        </service>
    </widget>

    <widget type="3" name="today_state" caption="Estado de ventas" flags="4">
        <service name="pd_today_orders00001" caption="Pedidos" desc="Nº pedidos del día" type="3" detail="1">
            <xvalue>0</xvalue>
            <xcolor>2</xcolor>
            <xalert>No se está vendiendo nada</xalert>
        </service>

        <service name="pd_today_sales00001" caption="Importe" desc="Importe ventas del día" type="3" detail="1">
            <xvalue>0,00</xvalue>
            <xcolor>2</xcolor>
            <xalert>No estamos recaudando nada</xalert>
        </service>
    </widget>
</widgets>

Loaded the xml and is ready to be tried, but I can not get all the fields you need

I need:

  • id,
  • caption attribute of the widget,
  • the services of each widget,
  • the caption attribute of service,
  • xValue,
  • xcolor and xalert,
  • each service

I get to get all the widgets, like this: (I think two kinds: Employees and Employee)

[XmlRoot("widgets")]
public class Employees
{
    [XmlElement("widget")]
    public ObservableCollection <Employee> Coleccion { get; set; }
}


 public class Employee
 {
    [XmlAttribute("caption")]
    public string nombreWidget { get; set; }
 }

But not like getting inside each widget their respective services (service attribute), and within these xValue, xcolor and xalert

  • 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-16T05:08:59+00:00Added an answer on June 16, 2026 at 5:08 am

    LinqToXml solution:

    var xml = XDocument.Parse(Resource1.XMLFile1).Root;
    var parsed = new {
                         Id = xml.Element("id").Value,
                         Widgets = xml.Elements("widget")
                                      .Select(w => new
                                      {
                                          Caption = w.Attribute("caption").Value,
                                          Services = w.Elements("service").Select(s => new
                                          {
                                              Caption = s.Attribute("caption").Value,
                                              XColor = s.Element("xcolor").Value,
                                              XValue = s.Element("xvalue").Value,
                                              XAlert = s.Element("xalert") != null ? s.Element("xalert").Value : null
                                          }).ToList()
                                      }).ToList()
                     };
    

    It will creates anonymous objects representing your inpout XML. You can easily replace that anonymous objects from my code with your real domain objects (Employees etc.).

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

Sidebar

Related Questions

I have tried changing xml values with the help of jdom by referring this
In my values.xml file, I have an array, like this; <string-array name=animals-array> <item>Cow</item> <item>Pig</item>
I'm using Linq to get some xml values, but this time I want to
hey i'm attempting to pass xml values using this hidden form: <form method='post' action='addholiday.php'
Please help with below mentioned scenario-> I am having wanna display values from 1
I am trying to generate unique values in c# with the help of DateTime
Please I need your help with my script. I'm trying to insert values into
wonder if someone could help me with a little problem. I have session values
Here is an example of the XML I'm trying to get some values from:
I have the following in my build.xml: <target name=compile.baz depends=init> <javac destdir=${build.dir}/classes debug=on> <compilerarg

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.