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
Solved

DataSet cannot expand entities.

Posted on 2006-07-14
7
857 Views
Last Modified: 2012-05-05
I have a XML file categories.xml like this

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="Products.xsd">
<Products>
<Description>500 ds yxHkx tM+h&cwfV;ksa o lk/kw lU;kfl;ksa dh vkSkf/k;kWa vkSj pqVdqyksa ls cus lSdM+ksa jksfx;ksa ij vktek;s uqL[ksA</Description>
</Products>
</dataroot>

I want to read this in a Dataset. I am using this code
dstCategories.ReadXml (HttpContext.Current.Request.MapPath("Categories.xml"))

The dataset cannot correctly read this XML file since I beleive due to characters + & ; etc in the node <Description> I cannot remove these characters. How can I possibly read these characters in data SET
The error returned is :

DataSet cannot expand entities. Use XmlValidatingReader and set the EntityHandling property accordingly.
0
Comment
Question by:skvikram
  • 4
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17110252
Hi skvikram,

your XML is not valid
you either need to replace the & by &amp;
or add a doctype to expand the entity &cwfV;

If you need the second option, I can show you hox,
but I think you need the first option

since & starts an entity, you need a special entity to indicate &, which is &amp;

Cheers!
0
 
LVL 7

Author Comment

by:skvikram
ID: 17113683
I know I cannot include & in XML-nodes.
But I still need to have it which I already clarified in my original question.
I mean I cannot change the contents of nodes.

Is there any way I can disable XML Validation
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17114176
> Is there any way I can disable XML Validation

not if you send this document to an XML processor such as an XSLT engine.
XML tools require XML
what you have there is strictly speaking not an XML document (it is not wellformed)
it is only something that looks like one.

The one who gave you this XML did a bad job.
You can recover from this with a pre-process
you can use some regular expressions (in Python, Perl, or Java...) to replace the & with &amp;
and then send it to the XSLT

cheers

Geert
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 7

Author Comment

by:skvikram
ID: 17120037
Dear Gertone,
The node contents of this XML file is some encrypted message so it has to remain this way else the entire purpose of encryption will be defeated.

What I need is any mechanism by which this XML file can be successfully transferred to DATASET.
0
 
LVL 7

Author Comment

by:skvikram
ID: 17160615
There are no acceptable solution to my original problem?
what's is happening experts??

Can I safely assume that I'll not be getting any further solution and assume this question as abandoned?
Page editor please look into the matter.
Thanks.
0
 
LVL 7

Author Comment

by:skvikram
ID: 17176274
Can I delete this questions as I am not getting any responses.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 125 total points
ID: 17211847
Hi, I was on holidays for some time.
As I stated before... the XML is not wellformed
If you want to include an encryption mechanism in your XML
you have to make sure the encryption mechanism doesn't contain an "&" or an "<"
so you are using an encryption mechanism that is unsafe for XML

the only other option you have is to wrap the encrypted string in a CDATA section,
like this

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="Products.xsd">
    <Products>
        <Description><![CDATA[500 ds yxHkx tM+h&cwfV;ksa o lk/kw lU;kfl;ksa dh vkSkf/k;kWa vkSj pqVdqyksa ls cus lSdM+ksa jksfx;ksa ij vktek;s uqL[ksA]]></Description>
    </Products>
</dataroot>

hope this helps

cheers

Geert
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

765 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