Nacin na koji preuzimam podatke je sledeci:
F
Code:
var items = (from r in xmlDoc.Descendants("record")
select new
{
Title = r.Element("metadata").Element("title").Value,
Creator = r.Element("metadata").Element("creator").Value,
Subject = r.Element("metadata").Element("subject").Value,
Contributor = r.Element("metadata").Element("contributor").Value,
Description = r.Element("metadata").Element("description").Value,
Abstract_theses = r.Element("metadata").Element("description").ElementsAfterSelf("description").First().Value,
Univerzitet = r.Element("metadata").Element("publisher").Value,
// Fakultet = r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").First().Value,
// Fakultet1= r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").ElementAt(1).Value,
Fakultet2= r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").ElementAt(2).Value, //Za ovaj izbacuje gresku ako ne postoji
fakulteti = r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").Select(f => f.Value).ToArray(), //Ovo sam pokusao po savetu sa bencha, ali ne pomaze
Type = r.Element("metadata").Element("type").Value,
Format = r.Element("metadata").Element("format").Value,
Identefier = r.Element("metadata").Element("identifier").Value,
Language = r.Element("metadata").Element("language").Value,
Rights = r.Element("metadata").Element("rights").Value,
});
var items = (from r in xmlDoc.Descendants("record")
select new
{
Title = r.Element("metadata").Element("title").Value,
Creator = r.Element("metadata").Element("creator").Value,
Subject = r.Element("metadata").Element("subject").Value,
Contributor = r.Element("metadata").Element("contributor").Value,
Description = r.Element("metadata").Element("description").Value,
Abstract_theses = r.Element("metadata").Element("description").ElementsAfterSelf("description").First().Value,
Univerzitet = r.Element("metadata").Element("publisher").Value,
// Fakultet = r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").First().Value,
// Fakultet1= r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").ElementAt(1).Value,
Fakultet2= r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").ElementAt(2).Value, //Za ovaj izbacuje gresku ako ne postoji
fakulteti = r.Element("metadata").Element("publisher").ElementsAfterSelf("publisher").Select(f => f.Value).ToArray(), //Ovo sam pokusao po savetu sa bencha, ali ne pomaze
Type = r.Element("metadata").Element("type").Value,
Format = r.Element("metadata").Element("format").Value,
Identefier = r.Element("metadata").Element("identifier").Value,
Language = r.Element("metadata").Element("language").Value,
Rights = r.Element("metadata").Element("rights").Value,
});
E problem je kada ne postoji treci cvor, izbacuje: Additional information: Specified argument was out of the range of valid values.
Znam sta znaci, pokusao sam na vise nacina i saveta sa stackowerflowa da ignorisem nepostojece cvorove ili da im upisem praznu vrednost, ali nista ne uspeva.