I have a problem with reading XML which looks as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<connections xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<connection id="1" odcFile="C:\Users\andr\Documents\My Data Sources\ELITE_MSSQLSERVER2012 PSO Reports.odc" keepAlive="1" name="ELITE_MSSQLSERVER2012 PSO Reports" type="5" refreshedVersion="5" background="1">
<dbPr connection="Provider=MSOLAP.5;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=PSO;Data Source=ELITE\MSSQLSERVER2012;MDX Compatibility=1;Safety Options=2;MDX Missing Member Mode=Error" command="Reports" commandType="1"/>
<olapPr sendLocale="1" rowDrillCount="1000"/>
</connection>
</connections>
(it's actually a connection.xml file in *.xlsx package). I'm trying to read it with the help of XDocument. I need to change the "odcFile" property. The problem is that it reads the whole thing as a single element without children elements. Why so? XML looks normal. Or maybe there is another workaround to make this?
d.Element(System.Xml.Linq.XNamespace.Get("http://schemas.openxmlformats.org/spreadsheetml/2006/main") + "connections").Element(System.Xml.Linq.XNamespace.Get("http://schemas.openxmlformats.org/spreadsheetml/2006/main") + "connection").Attribute("odcFile").SetValue("value");
(where d is theXDocument
and value is the value you want to changeodcFile
to)?