У меня есть следующий XML (часть RDL-отчета):Чтение XML с проблемой XDocument
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
<DataSources>
<DataSource Name="TMSSharepointDataSource">
<DataSourceReference>TMSSharepointDataSource</DataSourceReference>
<rd:DataSourceID>f06ffa33-238f-4d83-adfe-1eaa8df96e90</rd:DataSourceID>
</DataSource>
</DataSources>
</Report>
Я пытаюсь разобрать и прочитать его, используя следующий код:
byte[] fileContent = File.ReadAllBytes(@"path");
UTF8Encoding unicode = new UTF8Encoding();
string stringContent = unicode.GetString(fileContent);
XDocument xml = XDocument.Parse(stringContent);
XElement dsNode = xml.Root.Element("DataSources");
Я могу» t выяснить, почему dsNode всегда null?
какой-либо причине вы используете File.ReadAllBytes + UTFEncoding + XDocument.Parse вместо того, чтобы просто XDocument.Load? http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.load.aspx – dtb
yep, в «код назначения» (это был всего лишь тестовый код). Я получаю байтовый массив как input – agnieszka