Up vote 1 down vote favorite share g+ share fb share tw.
I need to have XML encoding and version at the top of my XML document which I am making with XDocument. I have this but it is in lowercase, and it needs to be in uppercase. What do I need to do?
I declare a new XML document using the XDocument class called 'doc'. I save this to a file using doc.Save();. I have tried: doc.Declaration.Encoding.ToUpper(); Declaring a new XDeclaration Typing the Encoding in uppercase and setting my doc.
Declaration to my XDeclaration. It still comes through in lowercase. C# .net xml declaration xdocument link|improve this question edited Dec 17 '11 at 20:49Kirill Polishchuk16.7k21228 asked Dec 17 '11 at 20:19JMK623110 100% accept rate.
It should make no difference to a standards conformant XML parser. – Oded Dec 17 '11 at 20:24 I agree, however it's not up to me, it needs to be in uppercase. I have tried "doc.Declaration.Version.
ToUpper", declararing a new XDeclaration, typing the version in uppercase and setting my "doc. Declaration" to my XDeclaration. It still comes through in lowercase, I am using doc.Save(); thanks – JMK Dec 17 '11 at 20:28 Please edit your question and update it with the details you just put in your comment.
These may be overlooked by people reading your question otherwise. – Oded Dec 17 '11 at 20:30 Did you try looping through all doc. Declaration attributes and ToUppering the attribute names?
– Oded Dec 17 '11 at 20:31 Yes, I get Object reference not set to an instance of an object. When I try 'doc.Declaration. Version = "UTF-8";' I get the same error on this line of code.
– JMK Dec 17 '11 at 20:34.
You can create custom XmlTextWriter, e.g. : public class CustomXmlTextWriter : XmlTextWriter { public CustomXmlTextWriter(string filename) : base(filename, Encoding. UTF8) { } public override void WriteStartDocument() { WriteRaw(""); } public override void WriteEndDocument() { } } Then use it: using (var writer = new CustomXmlTextWriter("file. Xml")) { doc.
Save(writer); }.
Perfect, thankyou so much! – JMK Dec 17 '11 at 20:56 @Heisenburg, You're welcome! – Kirill Polishchuk Dec 17 '11 at 20:56 It's very far from perfect.
It's not even XML. XML allows (indeed prefers) the encoding name to be in upper case, but the keywords "encoding" and "version" must be lower case. – Michael Kay Dec 18 '11 at 0:11 @MichaelKay, Do you have any complaints to my code?
– Kirill Polishchuk Dec 18 '11 at 8:37.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.