473,385 Members | 1,397 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,385 software developers and data experts.

Maddening working with .NET/.XSDs

Hey there,

Just starting out messing with XML in .NET. I'm just trying to read some
simple XML that I'm using to pass data structures between programs.
Something like this:

<?xml version="1.0" encoding="utf-8"?>
<Chris>
<One>1</One>
<Two>2</Two>
</Chris>

So I create the above in a file, create a matching XSD in Visual Studio, and
use a FileStream and XmlSerializer to try and read the thing in. I always
get an error at (2,2) unless I make the 2nd line look like this:

<Chris xmlns="http://tempuri.org/Chris.xsd">

I'm presuming that it doesn't want to parse it because it's trying to match
this line in my auto-generated .CS file:

[System.Xml.Serialization.XmlRootAttribute(Namespac e="http://tempuri.org/Chris.xsd", IsNullable=false)]

Do I have to have this xmlns deal in that line or what?

Thanks!

Jan 12 '07 #1
2 1243
cada0310 wrote:
So I create the above in a file, create a matching XSD in Visual Studio, and
use a FileStream and XmlSerializer to try and read the thing in. I always
get an error at (2,2) unless I make the 2nd line look like this:

<Chris xmlns="http://tempuri.org/Chris.xsd">

I'm presuming that it doesn't want to parse it because it's trying to match
this line in my auto-generated .CS file:

[System.Xml.Serialization.XmlRootAttribute(Namespac e="http://tempuri.org/Chris.xsd", IsNullable=false)]

Do I have to have this xmlns deal in that line or what?
You can simply use
[System.Xml.Serialization.XmlRootAttribute]
or
[System.Xml.Serialization.XmlRootAttribute(IsNullab le=false)]
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 12 '07 #2
Which version of xsd.exe are you using? When I generate a schema from a bit
of XML (although I typically leave out the <?xml?part), I get:
// This source code was auto-generated by xsd, Version=1.1.4322.2032.

[System.Xml.Serialization.XmlRootAttribute(Namespac e="", IsNullable=false)]

"cada0310" <ca******@discussions.microsoft.comwrote in message
news:9D**********************************@microsof t.com...
Hey there,

Just starting out messing with XML in .NET. I'm just trying to read some
simple XML that I'm using to pass data structures between programs.
Something like this:

<?xml version="1.0" encoding="utf-8"?>
<Chris>
<One>1</One>
<Two>2</Two>
</Chris>

So I create the above in a file, create a matching XSD in Visual Studio,
and
use a FileStream and XmlSerializer to try and read the thing in. I always
get an error at (2,2) unless I make the 2nd line look like this:

<Chris xmlns="http://tempuri.org/Chris.xsd">

I'm presuming that it doesn't want to parse it because it's trying to
match
this line in my auto-generated .CS file:

[System.Xml.Serialization.XmlRootAttribute(Namespac e="http://tempuri.org/Chris.xsd",
IsNullable=false)]

Do I have to have this xmlns deal in that line or what?

Thanks!

Jan 12 '07 #3

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

Similar topics

0
by: peter greaves | last post by:
hi everyone i am having a bad time with an entity resolver. my application uses a resolver to locally-cache the nested schemas that the basic xsd includes to a local directory. however i am...
0
by: Paul Sheer | last post by:
I would like to compile an XSD into a C/C++ header with functions to generate and parse XML messages. I understand that XMLBeans and Enhydra do this for Java. XBinder, Liquid, and some others...
6
by: Mullin Yu | last post by:
hi, i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working therefore, i want to have a unique sub...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
2
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
4
by: qbproger | last post by:
I'm developing a plugin for some software. The previous version of the software didn't require a start in directory to be set. This allowed me to leave the working directory to the default in the...
3
by: GaryDean | last post by:
In a new 2.0 website I am developing I am using .XSD tableadapters, building them with the wizard), and choosing the Stored Procedure option. I now notice that when I go back to change the sql...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.