This is XML structure:
<items>
<item>
<title>Weź udział w grze historycznej</title>
<link>https://legionowo.pl/a/wez-udzial-w-grze-historycznej</link>
<description><![CDATA[<img src="https://legionowo.pl/img/artykuly/4/2022_07/x41594.jpg.pagespeed.ic.9BJkaqvzdK.jpg%22%3E<br><br>]]></description>
<pubDate>Fri, 01 Jul 2022 09:10:50 +0000</pubDate>
<media:content url="https://legionowo.pl/img/artykuly/4/2022_07/x41594.jpg.pagespeed.ic.9BJkaqvzdK.jpg" medium="image" />
<guid isPermaLink="false">https://legionowo.pl/a/wez-udzial-w-grze-historycznej</guid>
</item>
<items>
this is C# method:
private async Task _XElementGet()
{
XElement doc = XElement.Load("C:\\mail.xml");
List<XElement> list;
list = (from prod in doc.Elements("item")
select prod).ToList();
foreach(XElement item in list)
{
Console.WriteLine(item.Name);
}
}
and its empty, but when i am trying to use XDocument it works and it looks:
private async Task _XDocumentGet()
{
XDocument doc = XDocument.Load("C:\\mail.xml");
List<XElement> list;
list = (from prod in doc.Descendants("item")
select prod).ToList();
foreach(XElement item in list)
{
//Console.WriteLine(item.Element("title"));
Console.WriteLine(item.FirstAttribute.Value);
}
}
This is first.
Second is about this Attribute "media:content" -> i cannot get its value because i get this error message:
System.Xml.XmlException: 'The ':' character, hexadecimal value 0x3A, cannot be included in a name.' how to read value from this attribute
Any ideas how i can fix it?