Solved

DataSet cannot expand entities.

Posted on 2006-07-14
7
850 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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, …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now