suppressing xsd namespace declarations with XmlSerialize?

Hi...

I'm just starting to play around with xml serialization.  Is there any way 
to suppress the xsd and xsi declarations in the resulting xml?  It doesn't 
appear that they're used but they come out anyway.

Thanks
-Mark

0
mmodrall1 (25)
1/25/2007 11:02:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
885 Views

Similar Articles

[PageSpeed] 14

Hi Mark,

We need to perform more research on this issue . We will reply here as soon 
as possible. 
If you have any more concerns on it, please feel free  to post here. 

Thanks for your understanding! 
Best regards,
Wen Yuan

0
v-wywang (104)
1/26/2007 9:35:06 AM
Hi Mark,
Thanks for your wait.



If you don��t need xsi and xsd declaration with xml serialization, you can 
use XmlSerializerNamespaces object.



XmlSerializerNamespaces xmlnsEmpty = new XmlSerializerNamespaces();
xlnsEmpty.Add("", "");
// Serialization
XmlSerializer s = new XmlSerializer(typeof(XmlSerializerClass));
TextWriter w = new StreamWriter(@"c:\list.xml");
s.Serialize(w, myList,xmlnsEmpty);
w.Close();



Please feel free to reply me if there is anything unclear, and we will 
follow up.

Have a great weekend!
Best regards,
Wen Yuan


0
v-wywang (104)
1/26/2007 4:08:47 PM
Thanks Wen Yuan...  That was exactly what I needed.

Mark


"WenYuan Wang" wrote:

> Hi Mark,
> Thanks for your wait.
> 
> 
> 
> If you don¡¯t need xsi and xsd declaration with xml serialization, you can 
> use XmlSerializerNamespaces object.
> 
> 
> 
> XmlSerializerNamespaces xmlnsEmpty = new XmlSerializerNamespaces();
> xlnsEmpty.Add("", "");
> // Serialization
> XmlSerializer s = new XmlSerializer(typeof(XmlSerializerClass));
> TextWriter w = new StreamWriter(@"c:\list.xml");
> s.Serialize(w, myList,xmlnsEmpty);
> w.Close();
> 
> 
> 
> Please feel free to reply me if there is anything unclear, and we will 
> follow up.
> 
> Have a great weekend!
> Best regards,
> Wen Yuan
> 
> 
> 
0
mmodrall1 (25)
1/26/2007 9:08:01 PM
Reply:

Similar Artilces:

How to suppress #VALUE!
After setting up functions, the spreadsheet appears ugly when there are empty input cells. Is there any method in suppressing the display of #VALUE! etc, say assigning white colour to these error words? Thanks! Fix the errors, dont just hide them, eg Instead of your_formula that appears to give you the error when an input cell is empty (assume it is A1), try =IF(A1="","",your_formula) -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ------------------------------�-------------------...

Xpath with Namespace retruns NULL, please help
I am using the following code to query for a single node, yet my results are always NULL. Please help, I've tried everything adn I am unable to get a result. XmlDocument xml = new XmlDocument(); xml.LoadXml(strNLETSMessage); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable); nsmgr.AddNamespace("n", "http://www.nlets.org"); nsmgr.AddNamespace("j", "http://www.it.ojp.gov/jxdm/3.0"); XmlNode test = xml.SelectSingleNode("/n:NLETS/n:NLETSInquiryMes...

xml namespace
Hi: One of the attribute in my XML document is xml:id. how can I add this attribute to a XmlElement? I tried to use http://www.w3.org/XML/1998/namespace as name space in the SetAttribute function, but it doesn't work. * Jinsong wrote in microsoft.public.dotnet.xml: >One of the attribute in my XML document is xml:id. how can I add this >attribute to a XmlElement? I tried to use >http://www.w3.org/XML/1998/namespace as name space in the SetAttribute >function, but it doesn't work. http://www.w3.org/mid/EB0A327048144442AFB15FCE18DC96C704E82CEB@RED-MSG-31.redmond.corp.micro...

How to suppress "Entourage cannot find server" message when offline?
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: Exchange Greetings. I'm a frequent traveler, and I can only access my email when connected to a VPN. When I am offline, I get the following error every time I send an email. <br><br>&quot;Entourage cannot find the server. Verify the server information is entered correctly in the Account Settings, and that your DNS settings in the Network pane of System Preferences are correct. <br><br>Mail could not be sent. Error -3176&quot; <br><br>What I wan...

Suppressing
I have a report that has a table with basically one grouping. I have sever rows of the same group and another table inside each of the rows. So basically I have 25 rows od the same group with a different table inside eavh row. So table inside of a table. My problem is that whenever one of the group tables has no data, it still shows whitespace and I cant get it to suppress when its blank. Any ideas? hi, can you set the width=0 and then set the visible for that row=false. Regards VB "Ben Watts" wrote: > I have a report that has a table with basica...

Does xsd.exe support spaces in file paths?
Does the xsd.exe command line support paths with spaces? For example the xsd.exe /o: option specifies the output file name. How can I specify an output file path that has a space? I'v tried googling up and down and cannot find an answer. Ken Brubaker wrote: > Does the xsd.exe command line support paths with spaces? > > For example the xsd.exe /o: option specifies the output file name. How can I > specify an output file path that has a space? The command line shell allows you to quote file names e.g. "file name.xml" Does that not work if you use xsd.exe? ...

XML import and XSD Schema
Is it possible to set an xsd schema to import data in excel from an xml file? Excel "intelligent" way to import data from xml is too "smart"! We have phone numbers that begin with 0, and excel thinks that are numbers and trim the first zero. Thanks for any help Yes, but, you need Microsoft Office 2003 Professional Edition for XML support http://www.microsoft.com/office/editions/prodinfo/technologies/xml.mspx Z�rcher See wrote: > Is it possible to set an xsd schema to import data in excel from an xml > file? > Excel "intelligent" way to import dat...

Suppress X Axis Scaling
I have a table I’m charting. There are 15 textual descriptions in a column and 6 date field headings. When I grab that table and switch the “Series In: to rows, the chart builds correctly – to some degree. Though there are only 6 contiguous date field headings, the dates are not. Is there a way to suppress the X Axis Scaling to show only the dates associated with this table, not adding filler dates that do not exist for this data? Sincerely, Arturo D'oh! An apostrophe at the beginning of the date does the trick… "Arturo" wrote: > I have a table I’m charting. Th...

Validation of a stack of XSD files (.NET 2.0)
I'm having a problem working out the classes and settings required to do this validation: There is a folder tree structure of 70+ XSD files that has a start point (parent XSD) which relates to all of the others via include or import. Of course a particular include may point to another XSD that itself has includes. And so on. The location of the XSD would be like C:\standard\folder1\first.xsd I don't need to validate an XML file yet. It's just to check that the existing stack of XSD files have correct relative addressing, etc. The XmlResolver should be able to process the xs...

suppression
Hi, my problem is the suppression of a recording to àpartir of a list indeed when I want to remove a customer for example an error message is posted: impossibe to remove contact the system administrator Thanck You Please stop workflows related to that list / record and also close activities related to that. It is basically because useable record. -- Regards, MS CRM Certified Professional http://microsoftcrm3.blogspot.com Chat with me on MSN / Gmail / Skype : ID Is :.. mscrmexpert@gmail.com "ahmed" wrote: > Hi, my problem is the suppression of a recording to ...

Suppressing VBA Errors
I think I've seen a way to prevent (supress?) errors in VBA but hav forgotten just how I should do it. This is my code. As you can see, it's to update data in a Currenc Conversion file that I made. Sub CurrencyUpdate() Range("C5").Select Selection.QueryTable.Refresh BackgroundQuery:=False End Sub Sometimes I get a Run-time error '1004' message saying "This web quer returned no data". Any solutions? Would appreciate any help -- Message posted from http://www.ExcelForum.com Hi have a look at on error resume next and on error goto 0 -- Regards Frank Kab...

suppress detail in a report?
I have a trial version of MS Money 2004. I want to generate a report based on Classification 1 and would like to see a summary only with no detail.. just the amounts for each Classification. I do not see an option in the custom report generator to suppress the detail (in Rows & Columns). Have I overlooked this option? If so, how do I accomplish this? Thanks! Have you tried Spending by Category with Customize|Rows & Columns|Rows:Classification 1 and Columns:Totals Only??? "speedlever" <speedlever@yahoo.com> wrote in message news:965b1a76.0308130430.69d03f29@posting.g...

Namespace references in Xml Serialization
I have a root node attribute which contains a name space declaration. I'd like to put a reference onto the front of it (ie: ns1:RootNode) where ns1 is defined as the namespace I'm using. Is there a way to do this in C#? Also can I include other namespaces in this declaration as well? Matt, I answered that question here in the group just yesterday ;): The best way is to pass an XmlSerializerNamespaces object to the Serialize() method, as I describe in [0]. You could also modify the generated class to force the namespace prefix when serializing instances [1], but I am generall...

XSD help
Hi all I have a config file like so <config> <optionSet1> <option index="1" name="Set 1 index 1"/> </optionSet1> <optionSet1> <option index="1" name="Set 2 index 2"/> </optionSet1> </config> optionSet1-index1 can only have set values 1, 3, 5, 7 How do I define XSD for optionSet2-index1 so that if optionSet1-index1 is in 1, 5 then it must be null if optionSet1-index1 == 3 then it must be A or B if optionSet1-index1 == 7 then it must be B, C or D Thank you very much! P...

Map XSD/XML data to VB.net classes
Hi, That's my first post here so I hope this is the right group to post to. I have to design a good strategy to manipulate XML data in VB.net language. Here's the business case: - I will have a large number (200+) of XML forms created with Infopath that represents industrial machines specifications. Infopath makes a XSD available for each form template. - These forms templates will be maintained by non programmers. - I am building an application that gathers form data to compute several indicators (cost, volume, weight...) based on the data inside the XML files created by Infopath. I...

Suppress UI of Dialog box.
i want to suppress the ui show after installing the cab in the PPC using SHELLEXECUTEINFO. i have tried sei.cbSize = sizeof(sei); sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS ; sei.hwnd = NULL; sei.lpVerb = _T("open"); sei.lpFile = tszCabPathName; sei.lpParameters = _T("safe /noui /nouninstall /delete 0"); sei.lpDirectory = _T(""); sei.nShow = SW_HIDE; still it shows successful installation of cab, and i want to avoid that dailog box. Can u please help me? Thanks, Bhavin "Bks" <bhavinshah.com@gmail.com> wrot...

Finding nested elements in XSD
I've got a schema loaded into a XmlSchema class. Via the elements collection I can see all the elements defiend at the root of the schema. How can I get the definition of a nested schema element? Thanks. Here's an example that shows how to traverse XmlSchema object. void Start() { XmlSchemaComplexType complexType; foreach (XmlSchemaType type in xs.SchemaTypes.Values) { complexType = type as XmlSchemaComplexType; if (complexType != null) TraverseParticle(complexType.ContentTypeParticle); } foreach (XmlSchemaElement el in xs.Elements.Values) TraverseParticle(...

Programmatically generate xsd from a type
Hi, I would like to generate an xml schema based upon a class, just as you can do with xsd.exe (xsd.exe /type: typename /outputdir:c:\ assmeblyname). Is there a way to do this by code instead of using this tool? Thanks in advance. I was convinced I'd seen a reference to xsd using some internal classes to this (that is it is just a wrapper). But I could not find it anywhere in MSDN (does not mean it is not there!). But I found this. http://weblogs.asp.net/cazzu/archive/2003/10/24/33302.aspx XmlSchemaExporter seems to the key thing here, but I have no idea what to do with it. Ple...

Suppress Update Links
Hi Is there a way to <turn off> the option to update links on a file which is being opened manually (as opposed to in VB). (There are a lot of VLOOKUPS in the file referencing an outside file). Thanks Tim Try: Tools > Options > Edit tab > Uncheck "Ask to update automatic links" > OK -- hth Max ----------------------------------------- Please reply in thread Use xdemechanik <at>yahoo<dot>com for email --------------------------------------------- "Tim Childs" <tsnip1@yahoo.co.uk> wrote in message news:f4efb325.0401080428.368d8e94@post...

Suppressing Views
Is there a way to suppress the system views in Outlook 2007 Tasks from displaying in the left bar? ...

Suppressing the Memo Field on Check Printing
Is there a setting on check printing that would not have the memo field print on checks, other than the solution to put everything in {} which requires manual intrevention on every check? Thanks, Steve No. But how did that require any more manual intervention than typing the memo in there in the first place? "Steve" <junkmail.t@comcast.com> wrote in message news:1817301c44a79$6bbd41c0$a601280a@phx.gbl... > Is there a setting on check printing that would not have > the memo field print on checks, other than the solution > to put everything in {} which requires man...

Namespaces and ReadXML
Hi everyone, I'm a real newbie, so please be patient :-) I am loading an XML files into a datagrid. It works fine. To further process the information, I need to identify the column type. This information is basically in the namespace: x-ALS means it's a picklist type and x-txt a non-picklist. <?xml version='1.0' ?> <tmx xmlns:x-TXT="http://www.x-txt.org" xmlns:x-ALS="http://www.x-als.org"> <tu> <x-ALS:Status>Approved</x-ALS:Status> <x-ALS:Department>Marketing</x-ALS:Department> <x-ALS:DocType>...

alternatives to suppress output
The following will destroy and recreate a subdirectory if (Test-Path subdir) {rmdir subdir -Recurse}; mkdir subdir but will produce output to the console: PS C:> if (Test-Path subdir) {rmdir subdir -Recurse}; mkdir subdir Directory: C:\Documents and Settings\Larry\My Documents\WindowsPowerShell Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 6/15/2010 6:01 AM subdir There are many ways to suppress the output to the console if (Test-Path subdir) {rmdir subdir -Recurse}; mkd...

Subreport Suppression
Hi all, I have a report with many subreports in it. The subreports have a table and a few text boxes inside of a rectangle. My problem is that when there is no dat for that subreport dataset, it just completely suppresses that subreport and I need it to show whether it has data or not. Can anyone help? Ben, I have 2 things you can try. Either set the properties for the report that when empty or it can't retrieve the subreport it spits out a text string you can set. Alternatively, make sure that the subreport is never empty. By this I mean if no rows are returned...

Parsing with unqualified Namespace
I am both producing and parsing an xml document that needs to be validated against a schema. I wanted some consumers of the document to have the option of not performing a validation, so I left the nodes in the instance unqualified. An example of the document is below: <?xml version="1.0" encoding="utf-8" ?> <filingreceipt xmlns="http://www.disclosureusa.org/filingreceipt.xsd"> <cpofilingnumber>TX2004043037501</cpofilingnumber> <receiptdate>2004-05-01T16:54:21</receiptdate> <zipfilebytes>95137</zipfilebytes> <rec...