473,394 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DataSet.XmlReader hangs when & is in string within XML file

I am trying to create a dataset from an XML file. When calling
myDataSet.ReadXml("sample.xml") the code produces an exception error. The
XML file has many strings that identify pnp ids on a system. These string
values contain multiple "&" signs within them (e.g.
<pnpid>PCI\VEN_1000&DEV_8000&SUDEV_1008<\pnpid>) . How can I correctly read
these pnp ids into a dataset?

I've tried using ReadXml with various stream readers(StreamReader or
TextReader) but they cause the same error.
--
-----------
Thanks,
Steve
Aug 18 '06 #1
4 2647
Well, the data simply isn't XML. Rather than trying to "fix" the reader
*correctly* telling you this, I'd fix whatever is writing the invalid
"XML" files. It should read:
<pnpid>PCI\VEN_1000&amp;DEV_8000&amp;SUDEV_1008<\p npid>

Which is read as an element "pnpid" with text content
"PCI\VEN_1000&DEV_8000&SUDEV_1008"

This is often caused by people using string concatenation to write
"xml", instead of (e.g.) XmlWriter (which would have dealt with this
automatically).

Marc

Aug 18 '06 #2
Eeks it gets worse: I didn't spot it first time: the trailing slash is
in the wrong direction too!!!!

<pnpid>PCI\VEN_1000&amp;DEV_8000&amp;SUDEV_1008</pnpid>

Marc

Aug 18 '06 #3
This makes a lot of sense. I changed my sample file to & and it worked just
fine. I will be creating the "writer" as well so this will be taken into
account. Thanks very much.
--
-----------
Thanks,
Steve
"Marc Gravell" wrote:
Eeks it gets worse: I didn't spot it first time: the trailing slash is
in the wrong direction too!!!!

<pnpid>PCI\VEN_1000&DEV_8000&SUDEV_1008</pnpid>

Marc

Aug 18 '06 #4
Hi Steve,

Yes, as Marc said, the & char is a reserved word in XML. So it will be
better to use an XmlWriter or XmlDocument to generate XML files. They will
automatically escape the reserved words for you.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: .Net_Newbie | last post by:
Hello, gurus I have a problem about format XML I use ms data access building block to get a data set from stored procedure. the dataset's save xml give me data with the elements. Is there any...
0
by: Patrick Kearney | last post by:
Hi All, I have seen this type of question raised in various groups but no one has supplied a definitive answer. I am trying to load a dataset schema that has an xs:include. Project policy is to...
1
by: Tarun Upadhyay | last post by:
I am trying to read the standard UDDI schema using a DataSet. however, it always chokes with error. Here are the full details: Schema used: http://uddi.org/schema/uddi_v3.xsd C# (.NET) calls...
8
by: Nikhilesh Mehendale | last post by:
I have written a web service in C#, .NET 1.1 which reads a XML file into a dataset. This is just a plain XML file. First I use the Dataset.ReadXmlScheme function and pass the XML file to it. Then...
5
by: George Durzi | last post by:
Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I do that? Thanks!
2
by: Amit | last post by:
I have assigned a simple xml into a XmlReader. A switch case loops through the nodes and writes the data to XmlWriter object which is initialized to a xml file. The output xml file is correctly...
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
2
by: Henrik | last post by:
Hi, I'm really stuck with this one. I have a dataset with two tables. One table is company data, and the other is contacts. I populate these by using a SP in SQL Server which returns the two...
2
by: Brent | last post by:
I'm trying to figure out which column an XML attribute belongs to when read into a dataset. Take the following XML fragment: <FileList> <file name="file1"></file> <file name="file2"></file>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.