XmlTextReader myXmlReader = new XmlTextReader(a rgs[0]);
string en = myXmlReader.Enc oding.EncodingN ame;
//Console.WriteLi ne(x);
Error:
Unhandled Exception: System.NullRefe renceException: Object
reference not set to
an instance of an object.
HOW CAN I GET THE ENCODING NAME ? Basically determine the
encoding type.
Also How can I "set" an application wide Encoding ? I want
all modules and everything to stick to and conform to UTF-
8.
But somehow some methods automatically go to UTF-16 4 3380
xmlguy wrote: XmlTextReader myXmlReader = new XmlTextReader(a rgs[0]); string en = myXmlReader.Enc oding.EncodingN ame; //Console.WriteLi ne(x);
Error:
Unhandled Exception: System.NullRefe renceException: Object reference not set to an instance of an object.
HOW CAN I GET THE ENCODING NAME ? Basically determine the encoding type.
You have to call Read() method at least once if you want to get Encoding
property. That's because XmlReader is pull-mode parser - it's your
responsibbility to call its Read() method to force it to read XML.
Encoding is stored in XML declarartion, which is always the very first
line in XML, so single Read() call would be enough to read it.
Also How can I "set" an application wide Encoding ? I want all modules and everything to stick to and conform to UTF- 8.
Elaborate please, what do you mean.
--
Oleg Tkachenko http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Is there any way to specify that all modules or
fns/methods in a given application follow only a single
encoding e.g. UTF-8
Because somehow I input my XML as UTF-8 and it
automatically comes out ast UTF-16.
How can i ensure application-wide setting/configuration
that it stick to one format. -----Original Message----- xmlguy wrote:
XmlTextReader myXmlReader = new XmlTextReader(a rgs[0]); string en = myXmlReader.Enc oding.EncodingN ame; //Console.WriteLi ne(x);
Error:
Unhandled Exception: System.NullRefe renceException:
Object reference not set to an instance of an object.
HOW CAN I GET THE ENCODING NAME ? Basically determine
the encoding type. You have to call Read() method at least once if you want
to get Encodingproperty. That's because XmlReader is pull-mode parser -
it's yourresponsibbilit y to call its Read() method to force it to
read XML.Encoding is stored in XML declarartion, which is always
the very firstline in XML, so single Read() call would be enough to
read it. Also How can I "set" an application wide Encoding ? I
want all modules and everything to stick to and conform to
UTF- 8. Elaborate please, what do you mean. -- Oleg Tkachenko http://www.tkachenko.com/blog Multiconn Technologies, Israel
.
xmlguy wrote: Is there any way to specify that all modules or fns/methods in a given application follow only a single encoding e.g. UTF-8
Because somehow I input my XML as UTF-8 and it automatically comes out ast UTF-16.
How can i ensure application-wide setting/configuration that it stick to one format.
I believe that's unfeasible and as well as quite unusual, so there is no
such functionality in .NET. Some situations doesn't allow UTF-8
altogether, e.g. strings are always UTF-16 encoded.
You have to take care of encoding issues on yours own. Beware of
implicit recodings.
--
Oleg Tkachenko http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Here's an interesting article discussing Unicode and character sets http://www.joelonsoftware.com/articles/Unicode.html
Eirik M.
"Oleg Tkachenko" <oleg@NO_SPAM_P LEASEtkachenko. com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. xmlguy wrote:
Is there any way to specify that all modules or fns/methods in a given application follow only a single encoding e.g. UTF-8
Because somehow I input my XML as UTF-8 and it automatically comes out ast UTF-16.
How can i ensure application-wide setting/configuration that it stick to one format.
I believe that's unfeasible and as well as quite unusual, so there is no such functionality in .NET. Some situations doesn't allow UTF-8 altogether, e.g. strings are always UTF-16 encoded. You have to take care of encoding issues on yours own. Beware of implicit recodings. -- Oleg Tkachenko http://www.tkachenko.com/blog Multiconn Technologies, Israel This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bill Cohagan |
last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm
trying to use redirection of the standard input stream to read input from a
(xml) file. The following code snippet is from this app:
===============================
static void Main(string args)
{
if (args.Length > 0) Console.SetIn(new StreamReader(args));
//executes...
|
by: Sangeetha Nagaraj |
last post by:
Hi,
I am writing a program to validate a XML file and i am getting an error.
Here is my Code, and i get an error at "args.Exception"
("The 'urn:books:catalog' element is not declared. An error occurred
at file:///c:/inetpub/wwwroot/LakisService/books.xml, (2, 2).")
private void Button2_Click(object sender, System.EventArgs e) {...
|
by: SqlJunkies User |
last post by:
I have pretty same problem with XmlDocument.Load(). It seems to appear after KB834623 hotfix installed. Here is the information to reproduce error:
Technical info:
• Windows XP Professional SP1
• .NET Framework 1.1
• KB834623 hotfix for .NET Framework 1.1 installed (installing with .NET Speech SDK 1.0)
Steps to reproduce:
1. Create...
|
by: stuart dent via .NET 247 |
last post by:
XML validation error. Help required
If anyone can help me, thankyou, thankyou...
When I run this code code I get this error:
The data at the root level is invalid. Line 1, position 39.
I can't work out what the error is. Can you???
original code:
Dim oRead As XmlTextReader
|
by: ecomputerdelicacy |
last post by:
Compact Framework SP3 (and I think also SP2 and SP1) XmlTextReader does not
handle !DOCTYPE and (maybe?) rdf elements. How can I get the XmlTextReader to
read these without issuing a NotSupportedException? Or at least to get past
these elements (and nested elements) with an Skip()? I've tried setting
xtr.XmlResolver = null; but it doesn't...
| |
by: Michael |
last post by:
Hi All,
I have something going wrong with the XmlTextReader. I have a function that
reads the following XML example. For some reason the code is only getting two
of the 3 Values elements. Here is some code I'm using:
Thanks for any suggestions.
<?xml version="1.0" encoding="windows-1252" ?>
<MMTP>
<LookUp>...
|
by: jasn |
last post by:
Hello
I am getting the following error message when I try and send an XML sting to
a web service, I read somewhere that most web services prefer ascii and some
throw errors when using unicode so I have changed the encoding but still cant
get rid of the error.
System.Xml.XmlException: '', hexadecimal value 0x00, is an invalid
character....
|
by: Cesar |
last post by:
Hello,
I've developed a .NET C# web service; which has one method named, let's say,
upload_your_data. This method has one parameter ( string your_data). The
value that this parameter will actually have is the content of a XML
document. This data will be processed and check for a well-formed xml
document and will be validated against a XSD....
|
by: Manikrag |
last post by:
Hi All,
I am getting error while am loading RSS Stream in XMLDocument object. The error is as follows.
"System.Xml.XmlException: '', hexadecimal value 0x19, is an invalid character. Line 18, position 32."
I understand that this is becasue I have one apostrophe in the RSS Feed.
I have tried few tricks to get rid of apostrophe but of no...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |