I have the following XML file. I have to add a node using XElement
and XAttribute
. How to do this?
<?xml version="1.0" encoding="UTF-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSets>
<DataSet Name="Data">
<Query>
<DataSourceName>DS1</DataSourceName>
<CommandText>SELECT FirstName,LastName FROM Person</CommandText>
</Query>
</DataSet>
<DataSet Name="table22">
<Query>
<DataSourceName>DS1</DataSourceName>
<CommandText>New text2</CommandText>
</Query>
How to add following XML text to above xml file at the end of both "/query" element using XElement
And XAttribute
<Fields>
<Field Name="ReportId">
<DataField>ReportId</DataField>
<rd:TypeName>System.Int64</rd:TypeName>
</Field>