0

Web サービスからの応答として取得している xml があります。

 <Production>
    <creator>...</creator>
    <creator.date_of_birth/>
    <creator.date_of_death/>
    <creator.history/>
    <creator.lref>426</creator.lref>
    <creator.qualifier/>
    <creator.role/>
    <creator.role.lref/>
    <production.notes/>
    <production.place>France</production.place>
    <production.place.lref>30</production.place.lref>
  </Production>
  <production.period>19th century</production.period>
  <production.period.lref>13</production.period.lref>
  <Production_date>
    <production.date.end>1863</production.date.end>
    <production.date.end.prec>circa.</production.date.end.prec>
    <production.date.start>1863</production.date.start>
    <production.date.start.prec>dated</production.date.start.prec>
  </Production_date>

以下は、値を取得するための私の LINQ コードです。

allrecs = (from XElement c in recordSet.Descendants("recordList")
                where c.HasElements
                from x in c.Elements("record")
                select new CollectionRecord()
                {
                  production_place =  x.Element("Production").Element("production.place").Value,
                  production_period =  x.Element("production.period").Value,
                  production_start_date = x.Element("Production_date").Element("production.date.start").Value,
                  production_end_date = x.Element("Production_date").Element("production.date.end").Value,
                }).ToList <CollectionRecord>();

私が見つけた問題は、「production.date.start」と「production.date.end」の値を取得できませんが、上記のコードは「production.period」で機能します。これらの要素の xml 構造とデータに問題はありません。私の理解によると、「abc」のような要素では機能しませんが、「ab」ではうまく機能します。他の同様の要素で確認したところ、機能しません!

4

1 に答える 1