Solved

Invalid Characters in XML

Posted on 2009-07-03
2
432 Views
Last Modified: 2012-05-07
Hi,

I am importing an XML file in c#.net using  .ReadXml(xmlFileName, XmlReadMode.InferSchema)

Part of the XML file has Cdata[] wrapped around the data, however, the exception invalid character is being thrown.  I thought the point of CData was to tell the importer that it is not mark up language.

Is there anything I can do to get this to pass?

thanks
0
Comment
Question by:kinton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24772300
well, indeed CDATA is not totally ignored by the parser. For example, cannot put a > sign inside CDATA, you have to use > to escape it. If not, CDATA will assume that is portion has finished. The same for other XML character entities:
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
0
 
LVL 12

Accepted Solution

by:
ShazbotOK earned 500 total points
ID: 24788215
Start with reading the Xml in using a XmlReader setting the validation to none then use the reader to import into the dataset - see if that does the job for you...
            System.Xml.XmlReaderSettings xmSettings = new System.Xml.XmlReaderSettings();
            xmSettings.ValidationType = System.Xml.ValidationType.None;
            System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(((System.IO.Stream)new System.IO.MemoryStream(System.Text.UTF8Encoding.UTF8.GetBytes("MyXmlString"))), xmSettings);
            System.Data.DataSet ds = new System.Data.DataSet();
            ds.ReadXml(reader);

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question