?
Solved

How do you prevent multiple DataTables from being created in the DataSet when there is a CData section in the XML?

Posted on 2005-04-06
4
Medium Priority
?
215 Views
Last Modified: 2010-04-16
I have an XML file that looks like the following:

<MessageList>
 <Msg>
    <msgId>5</msgId>
    <descr>Message #1</descr>
    <msgText>It is <![CDATA[<DISKINFO/PERCENT>]]> % full </msgText>
  </Msg>
 <Msg>
    <msgId>6</msgId>
    <descr>Message #2</descr>
    <msgText>Message number two</msgText>
  </Msg>
</MessageList>

I've got a list of messages, which may or may not have a CData section embedded in the msgText.  When I create a DataSet with this xml file, it creates 2 DataTables.  So when the data is displayed in a DataGrid, it displays some traversal links to get to the next table.  Is there a way to merge the two tables? I want all the data presented on the top level of the DataGrid. Anybody have any ideas how I can do that?  I'm currently doing it by creating my own columns and adding the values row by row.  Is there an easier way to do this without having to manipulate the DataGrid manually?

Thanks.
0
Comment
Question by:mromeo
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
WebSpecials earned 800 total points
ID: 13717290
A solution would be to mark the whole tag as CDATA... than its no problem, because CDATA is user for data containing Text with special characters.

<?xml version="1.0"?>
<MessageList>
 <Msg>
    <msgId>5</msgId>
    <descr>Message #1</descr>
    <msgText><![CDATA[It is <DISKINFO/PERCENT>full ]]> </msgText>
  </Msg>
 <Msg>
    <msgId>6</msgId>
    <descr>Message #2</descr>
    <msgText>Message number two</msgText>
  </Msg>
</MessageList>

Mabey you can get away with this solution.

mfg maZe
0
 

Author Comment

by:mromeo
ID: 13717340
Great!! That solves the problem.  Thanks.
0
 

Author Comment

by:mromeo
ID: 13717470
A similar thing happens if I have an attribute in one of my tags, ie.

<MessageList>
 <Msg versionNo="1">
    <msgId>5</msgId>
    <descr>Message #1</descr>
    <msgText>It is <![CDATA[<DISKINFO/PERCENT>]]> % full </msgText>
  </Msg>
 <Msg versionNo="1">
    <msgId>6</msgId>
    <descr>Message #2</descr>
    <msgText>Message number two</msgText>
  </Msg>
</MessageList>

Is there a way around this one?  Thanks.
0
 
LVL 2

Expert Comment

by:WebSpecials
ID: 13751132
hmmm i have no problem with this:

<MessageList>
 <Msg versionNo="1">
    <msgId>5</msgId>
    <descr>Message #1</descr>
    <msgText>It is <![CDATA[<DISKINFO/PERCENT>]]> % full </msgText>
  </Msg>
 <Msg versionNo="1">
    <msgId>6</msgId>
    <descr>Message #2</descr>
    <msgText>Message number two</msgText>
  </Msg>
</MessageList>

but there is again CDATA not outside <msgText><![CDATA[It is <DISKINFO/PERCENT>full ]]> </msgText>

with that it worked for me...
mfg WebSpecials
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

569 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