ekramer11
07-13-2006, 07:01 PM
I have successfully gotten my Xml editing actions to work. However, the final file appears to be changed in an way I didnt' specify when I was setting things up. I am dealing with .Net 2.0/ VS 2005. I am trying to write a connection string to the XML file based on user input.
My starting xml file looks like this...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear/>
<add name="ConnectionString" connectionString="<<connstring>>" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
This configuration works just fine with my app ( the actual connection string is removed of course ). What I am ending up with, after the XML View does it's editing is the following:
<?xml version="1.0" encoding="UTF-16"?>
<configuration>
<connectionStrings>
<clear></clear>
<add name="ConnectionString" connectionString="<<conn string>>" providerName="System.Data.SqlClient"></add>
</connectionStrings>
</configuration>
As far as I can tell, this is perfectly formed XML. However the added close tags for </clear> and </add> cause the ConfigurationManager object to not be able to find the specified connection string which causes the app to choke. If I remove them, and move the /> back to end end just like the original it works just peachy.
The only other difference I'm noting is the difference between UTF=16 and utf=8 in the header. But changing that doesn't make a difference.
Anyone have any idea what's going on with this?
My starting xml file looks like this...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear/>
<add name="ConnectionString" connectionString="<<connstring>>" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
This configuration works just fine with my app ( the actual connection string is removed of course ). What I am ending up with, after the XML View does it's editing is the following:
<?xml version="1.0" encoding="UTF-16"?>
<configuration>
<connectionStrings>
<clear></clear>
<add name="ConnectionString" connectionString="<<conn string>>" providerName="System.Data.SqlClient"></add>
</connectionStrings>
</configuration>
As far as I can tell, this is perfectly formed XML. However the added close tags for </clear> and </add> cause the ConfigurationManager object to not be able to find the specified connection string which causes the app to choke. If I remove them, and move the /> back to end end just like the original it works just peachy.
The only other difference I'm noting is the difference between UTF=16 and utf=8 in the header. But changing that doesn't make a difference.
Anyone have any idea what's going on with this?