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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:12:05+00:00 2026-06-11T23:12:05+00:00

For a C# project I’m querying an API, which returns me an XML similar

  • 0

For a C# project I’m querying an API, which returns me an XML similar to this:

<itemlist>
  <item attrib1="Value1" attrib2="Value2"... attrib15="Value15">
    <sometypeinfo1 attrib1="Value1" attrib2="Value2"... attrib15="Value15">
      <subelement>
        <someproperty attrib1="Value1" attrib2="Value2"/>
        <someproperty attrib1="Value1" attrib2="Value2"/>
        <someproperty attrib1="Value1" attrib2="Value2"/>
      </subelement>
    </sometypeinfo1>
    <sometypeinfo2>
      <subelement attrib1="Value1" attrib2="Value2">
        <someproperty>
          <somedescription attrib1="Value1" attrib2="Value2"/>
          <somedescription attrib1="Value1" attrib2="Value2"/>
        </someproperty>
      </subelement>
    </sometypeinfo2>
    <sometypeinfo3 attrib1="Value1" attrib2="Value2"/>
    <sometypeinfo4>
      <someproperty attrib1="Value1" attrib2="Value2"/>
    </sometypeinfo4>
    <sometypeinfo5>
      <someproperty attrib="somevalue"/>
    </sometypeinfo5>
    <somemodifiers>
      <somemodifier attrib1="Value1" attrib2="Value2"/>
      <somemodifier attrib1="Value1" attrib2="Value2"/>
      <somemodifier attrib1="Value1" attrib2="Value2"/>
    </somemodifiers>
    <someflags>
      <someflag attrib="somevalue"/>
      <someflag attrib="somevalue"/>
      <someflag attrib="somevalue"/>
    </someflags>
  </item>
  <item>
  .
  .
  .
  </item>
</itemlist>

Its basically a list with ~ 100 items/file and every one with alot of descriptions, attributes etc.
Now, thats not something unusual.
I have trouble mapping it into a class or dataset. For example this line

<sometypeinfo1 attrib1="Value1" attrib2="Value2"... attrib15="Value15">

One item may miss attrib1, another attrib2, a 3rd one may have all 15 etc.

Same with “Someflags”, there can be one item with 5 “someflag”s, the next one only with 2.
etc.
Every element or attribut CAN be there, but doesnt has to. So they all share a pool of elements/attribs, and this is where I get stuck with serialization etc.

Yes, I’m new to this. But from what I’ve learned so far, a schema has to have all elements/attribs to have the XML being mapped properly?

The only thing that comes to mind would be writing another tool that collects all possible elements etc., then writing a class that contains all, NULL everything in the first place and then just parse the XML, overwriting everything found in the actual item.

  • 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-11T23:12:06+00:00Added an answer on June 11, 2026 at 11:12 pm

    Most XML parsing tools represent the attributes of an element as a collection, and you can iterate over that collection.

    they also represent child elements as a collection too.

    Here’s some sample syntax using my XML parsing class of choice, but c# has multiple build in options that you can explore at your leisure.

            XmlDocument doc = new XmlDocument();
            doc.Load("myXML.xml");
            XmlNode node = doc.SelectSingleNode("//sometypeinfo1");
    
            foreach (XmlAttribute a in node.Attributes)
            {
                Console.Write(a.Name);
                Console.Write(a.Value);
            }
    

    here’s a further documentation on XPATH that i used here.

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

Sidebar

Related Questions

Project: ASP.NET 3.5 with C# I have this much :- A table which used
Project structure is: /foo pom.xml /foo-war pom.xml /foo-ear pom.xml This is my parent pom.xml
This project was coped almost exacatly from the example on the admob page but
This project is in Obj-C for iphone. I'm using the double float version of
Project Euler 126 says: If we then add a second layer to this solid
Our project's template html has a quirks declaration,which is <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML
My project is in XCode 4.2. This project compiles for a regular debug build.
Project : Game in Flex builder 4 (Actionscript Project) Language : Actionscript 3 This
My project is currently using a svn repository which gains several hundred new revisions
(This project is all written in JS) So, I have a table called paid_offers

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.