473,587 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to serialize correct XML headers

All,
I am trying to generate the following header when serializing a class
to XML

<FpML
version="4-0"
xsi:type="Trade Affirmation"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.fpml.org/2003/FpML-4-0
fpml-main-4-0.xsd"
xmlns="http://www.fpml.org/2003/FpML-4-0">
</FpML>

The class is currently declared as:
<System.Xml.Ser ialization.XmlT ypeAttribute([Namespace]:="http://www.fpml.org/2003/FpML-4-0"),
_
System.Xml.Seri alization.XmlRo otAttribute([DataType]:="TradeAffirma tion")>
_
Public Class FpML
End Class
This generates the following:
<FpML xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
</FpML>

I am unsure how to get my code to generate the header correctly. Any
ideas?

Many thanks
Paul

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 12 '05 #1
1 4976
PMNorris,
This class should get you the header you're looking for:

<System.Xml.Ser ialization.XmlT ypeAttribute([Namespace]:="http://www.fpml.org
/2003/FpML-4-0")> _
Public Class FpML
<XmlAttributeAt tribute()> _
Public version As String = "4.0"

<XmlAttributeAt tribute([Namespace]:="http://www.w3.org/2001/XMLSchema-instan
ce")> _
Public schemaLocation As String =
"http://www.fpml.org/2003/FpML-4-0fpml-main-4-0.xsd"

<XmlAttributeAt tribute([Namespace]:="http://www.w3.org/2001/XMLSchema-instan
ce")> _
Public type As String = "TradeAffirmati on"
End Class

To add the default namespace declaration, you need to pass the name of the
default namespace to the constructor of the XmlSerializer like this:
Dim ser As New XmlSerializer(G etType(FpML),
"http://www.fpml.org/2003/FpML-4-0")

--
HTH
Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor

"PMNorris" <pa*********@uk .nomura-dot-com.no-spam.invalid> wrote in message
news:3f******** **@127.0.0.1...
All,
I am trying to generate the following header when serializing a class
to XML

<FpML
version="4-0"
xsi:type="Trade Affirmation"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.fpml.org/2003/FpML-4-0
fpml-main-4-0.xsd"
xmlns="http://www.fpml.org/2003/FpML-4-0">
</FpML>

The class is currently declared as:
<System.Xml.Ser ialization.XmlT ypeAttribute([Namespace]:="http://www.fpml.org
/2003/FpML-4-0"), _
System.Xml.Seri alization.XmlRo otAttribute([DataType]:="TradeAffirma tion")> _
Public Class FpML
End Class
This generates the following:
<FpML xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
</FpML>

I am unsure how to get my code to generate the header correctly. Any
ideas?

Many thanks
Paul

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---
Nov 12 '05 #2

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

Similar topics

3
2154
by: CLEAR-RCIC | last post by:
Hi, I have a class that I am trying to serialize. To simplify, I've changed the names to Baseball, Teams and Players. Here is what the XML should look like: <BaseBall> <Teams> <Team> <Name /> <City />
14
14290
by: vince | last post by:
Can I add (append) to an xml file that already contains a serialized object, and be able to deserialize to either or both objects from the same file...??? How is this done...?? thanks, vince
5
24689
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream s); public void Deserialize(Stream s); Within the MyUserControl class, there is a field of type MyInnerClass
10
4140
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName; string s_FinalFileName; try
0
1547
by: Ken Durden | last post by:
I'm getting the following exception coming out of a block of unmanaged C++ code. Thread executed for 1.03 sec and died with the following exception: External component has thrown an exception. ==== Primary Call Stack ==== at...
1
1468
by: js | last post by:
Does anybody knows how to solve the problem? I added attribute to the following classes in Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get the error. Thanks. Database.cs DatabaseFactory.cs DatabaseProviderFactory.cs DBCommandWrapper.cs
3
4786
by: Jeff Richardson | last post by:
This is a repost from the InfoPath news group. Hi, I am writing a SharePoint application that works with InfoPath forms. When a user submits a completed InfoPath form to a forms library my code processes the posted xml file by reading the data into a C# class object that was generated by XSD.EXE. The class was generated from the...
1
39682
by: Tim | last post by:
Could anyone tell me what this means and how do I correct it. Any suggestions? Thanks! Tim Richardson IT Developer and Consultant www.paladin3d.com Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef...
2
2664
by: =?Utf-8?B?TW91dGhPZk1hZG5lc3M=?= | last post by:
How can I add an MD5 hash to XMLSerializer.Serialize without corrupting the content of the file; then how to read it back to verify is correct? I'd like to code up something (see below) that looks like this, but I'm not sure this is correct approach to the problem. Once I add the signature, the file won't test the same way again. I know I...
3
10229
by: Julie | last post by:
Here's the scenario (public attributes, etc. omitted for brevity): class Base { } class Derived : Base { }
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.