Hi,
I have a menu where I bind data through:
XmlDataSource xmlData = new XmlDataSource();
xmlData.DataFile = String.Format(@"{0}{1}\Navigation.xml", getXmlPath(), getLanguage());
xmlData.XPath = @"/Items/Item";
TopNavigation.DataSource = xmlData;
TopNavigation.DataBind();
The problem is when my xml has special characters, since I use a lot of french words.
As an alternative I tried using a stream instead and using encoding to get the special characters, with the following code:
StreamReader strm = new StreamReader(String.Format(@"{0}{1}\Navigation.xml", getXmlPath(), getLanguage()), Encoding.GetEncoding(1254));
XmlDocument xDoc = new XmlDocument();
xDoc.Load(strm);
XmlDataSource xmlData = new XmlDataSource();
xmlData.ID = "TopNav";
xmlData.Data = xDoc.InnerXml;
xmlData.XPath = @"/Items/Item";
TopNavigation.Items.Clear();
TopNavigation.DataSource = xmlData;
TopNavigation.DataBind();
The problem I'm having now is that my data doesn't refresh when I change the path where the stream gets read.
When I skip through the code it does, but not on my page.
So the thing is either, how do I get the data te be refreshed? Or (which is actually preferred) how do I get the encoding right in the first piece of code?
Help is highly apreciated!
EDIT:
I tried the CDATA solution, however i'm working with attributes so it's not possible to specify an element in an attribute, my xml:
<?xml version="1.0" encoding="utf-8" ?>
<Items Text="">
<Item Text="Actualités>"/>
<Item Text="Matériau">
<Item Text="Arsenal"/>
<Item Text="Vêtements"/>
</Item>
<Item Text="Links"/>
</Items>
Any other ideas?