Linq to XML - Extracting multiple elements with the same name to objects
I'm a S.O. newbie here looking for some help with Linq2XML. I am new to c# development and the software dev. industry as a whole and would like some guidance regarding the following problem.

**Problem**.

I have an XML document with Dublin Core metadata, that I would like to parse (preferably into objects) using LINQ to XML. I have removed the DC namespace to make the parsing of data easier and I have attempted to solve this myself (using countless methods) but can't seem to get the identifiers i.e. ID TEXT 1 & 2 from the xml.



Any guidance or even finger pointing @ my mistake would be highly appreciated.
Below is my xml & code snippet. The XML is just of 1 record, in fact it will be 100s if not 1000s so this must be able to populate say Books with- creator/s (can be more than 1), identifier/s (can be more than 1) and title.

**XML DOC EDITED SNIPPET (1 record)**

    <records>
     <record>
      <recordSchema>DC</recordSchema>
      <recordPacking>xml</recordPacking>
      <recordData>
        <oclcdcs>
          <creator>AUTHOR</creator>
          <date>2006</date>
          <description>TEXT</description>
          <description>TEXT</description>
          <description>TEXT</description>
          <format>FORMAT</format>
          <identifier>ID TEXT1</identifier>
          <identifier>ID TEXT2</identifier>
          <language p6:type="http://purl.org/dc/terms/ISO639-2" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">eng</language>
          <publisher>PUB TEXT</publisher>
          <relation p6:type="http://purl.org/dc/terms/URI" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">REL TEXT</relation>
          <relation p6:type="http://purl.org/dc/terms/URI" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">REL TEXT</relation>
          <title>TITLE TEXT</title>
          <type>Text</type>
          <recordCreationDate p6:type="http://purl.org/oclc/terms/marc008date" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">060508</recordCreationDate>
          <recordIdentifier p6:type="http://purl.org/oclc/terms/lccn" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">REC ID TEXT1</recordIdentifier>
          <recordIdentifier>REC ID TEXT1</recordIdentifier>
        </oclcdcs>
      </recordData>
     </record>
    </records>

**C# Code Attempt**

    var abc = (from y in xELE.Descendants("oclcdcs")
               select new
               {
                   title = y.Element("title").Value,
                   author = y.Element("creator").Value,
                   identities = (y.Elements("identities")
                                .Select(x => x.Value)
                                .ToList())
                });
                           
Gets me title and author but how do I use/retrieve the identities to set a list of strings. The identities are not populated as a list as I would expect it rather an IEnumerator.
                           
    
Thanks again.
Linq to XML - Extracting multiple elements with the same name to objects
===

I'm a S.O. newbie here looking for some help with Linq2XML. I am new to c# development and the software dev. industry as a whole and would like some guidance regarding the following problem.

**Problem**.

I have an XML document with Dublin Core metadata, that I would like to parse (preferably into objects) using LINQ to XML. I have removed the DC namespace to make the parsing of data easier and I have attempted to solve this myself (using countless methods) but can't seem to get the identifiers i.e. ID TEXT 1 & 2 from the xml.



Any guidance or even finger pointing @ my mistake would be highly appreciated.
Below is my xml & code snippet. The XML is just of 1 record, in fact it will be 100s if not 1000s so this must be able to populate say Books with- creator/s (can be more than 1), identifier/s (can be more than 1) and title.

**XML DOC EDITED SNIPPET (1 record)**

    <records>
     <record>
      <recordSchema>DC</recordSchema>
      <recordPacking>xml</recordPacking>
      <recordData>
        <oclcdcs>
          <creator>AUTHOR</creator>
          <date>2006</date>
          <description>TEXT</description>
          <description>TEXT</description>
          <description>TEXT</description>
          <format>FORMAT</format>
          <identifier>ID TEXT1</identifier>
          <identifier>ID TEXT2</identifier>
          <language p6:type="http://purl.org/dc/terms/ISO639-2" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">eng</language>
          <publisher>PUB TEXT</publisher>
          <relation p6:type="http://purl.org/dc/terms/URI" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">REL TEXT</relation>
          <relation p6:type="http://purl.org/dc/terms/URI" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">REL TEXT</relation>
          <title>TITLE TEXT</title>
          <type>Text</type>
          <recordCreationDate p6:type="http://purl.org/oclc/terms/marc008date" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">060508</recordCreationDate>
          <recordIdentifier p6:type="http://purl.org/oclc/terms/lccn" xmlns:p6="http://www.w3.org/2001/XMLSchema-instance">REC ID TEXT1</recordIdentifier>
          <recordIdentifier>REC ID TEXT1</recordIdentifier>
        </oclcdcs>
      </recordData>
     </record>
    </records>

**C# Code Attempt**

    var abc = (from y in xELE.Descendants("oclcdcs")
               select new
               {
                   title = y.Element("title").Value,
                   author = y.Element("creator").Value,
                   identities = (y.Elements("identities")
                                .Select(x => x.Value)
                                .ToList())
                });
                           
Gets me title and author but how do I use/retrieve the identities to set a list of strings. The identities are not populated as a list as I would expect it rather an IEnumerator.
                           
    
Thanks again.