Solved

DataSet cannot expand entities.

Posted on 2006-07-14
7
858 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
[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
  • 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
Industry Leaders: 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!

 
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

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

Suggested Solutions

Title # Comments Views Activity
msxml3.dll error '80072efd' A connection with the server could be not established 8 52
tutorial for ebay api 3 78
DTD and JAVA versions 1 29
Replace value 2 31
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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