xsi:noNamespaceSchemaLocation Problem



I use the following code to create the XML from a class object

        Dim serialize As New 
System.Xml.Serialization.XmlSerializer(GetType(XYZObject))
        serialize.Serialize(obWtiter, obObject)


But I need the following ' xsi:noNamespaceSchemaLocation="obj-envelope.xsd"' 
to be included in the in the main opening tag

How can I cause the XmlSerializer to do that?

Thank you,
Samuel 


0
8/7/2008 10:00:35 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
915 Views

Similar Articles

[PageSpeed] 23


"Samuel" <samuel.shulman@ntlworld.com> wrote in message 
news:O3KgGkN#IHA.3852@TK2MSFTNGP05.phx.gbl...
>
>
>
> I use the following code to create the XML from a class object
>
>        Dim serialize As New 
> System.Xml.Serialization.XmlSerializer(GetType(XYZObject))
>        serialize.Serialize(obWtiter, obObject)
>
>
> But I need the following ' 
> xsi:noNamespaceSchemaLocation="obj-envelope.xsd"' to be included in the in 
> the main opening tag
>
> How can I cause the XmlSerializer to do that?
>
> Thank you,
> Samuel
>
This seems to be what you are looking for: 
http://johnstewien.spaces.live.com/blog/cns!E6885DB5CEBABBC8!888.entry

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name 

0
8/8/2008 7:13:53 AM


"Joe Fawcett" <joefawcett@newsgroup.nospam> wrote in message 
news:%23RopSZS%23IHA.5036@TK2MSFTNGP04.phx.gbl...
>
>
> "Samuel" <samuel.shulman@ntlworld.com> wrote in message 
> news:O3KgGkN#IHA.3852@TK2MSFTNGP05.phx.gbl...
>>
>>
>>
>> I use the following code to create the XML from a class object
>>
>>        Dim serialize As New 
>> System.Xml.Serialization.XmlSerializer(GetType(XYZObject))
>>        serialize.Serialize(obWtiter, obObject)
>>
>>
>> But I need the following ' 
>> xsi:noNamespaceSchemaLocation="obj-envelope.xsd"' to be included in the 
>> in the main opening tag
>>
>> How can I cause the XmlSerializer to do that?
>>
>> Thank you,
>> Samuel
>>
> This seems to be what you are looking for: 
> http://johnstewien.spaces.live.com/blog/cns!E6885DB5CEBABBC8!888.entry
>
> -- 
>
> Joe Fawcett (MVP - XML)
> http://joe.fawcett.name


Thank you for the link,

I managed to add the xsd reference

The actual code didn't work so I wonder how can I set the encoding that the 
serelizer will use

Thank you,
Samuel 


0
8/8/2008 1:33:28 PM
Samuel wrote:
> "Joe Fawcett" <joefawcett@newsgroup.nospam> wrote in message 
> news:%23RopSZS%23IHA.5036@TK2MSFTNGP04.phx.gbl...

> The actual code didn't work so I wonder how can I set the encoding that the 
> serelizer will use

The Serialize method has several overloads
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.serialize.aspx
if you pass in a TextWriter it will use the encoding of the TextWriter, 
if you pass in an XmlWriter you can set the encoding with the 
XmlWriterSettings you create the XmlWriter with:
   Dim wSettings As New XmlWriterSettings()
   wSettings.Encoding = Encoding.UTF8
   Using xWriter As XmlWriter = XmlWriter.Create("file.xml", wSettings)
     serializer.Serialize(xWriter, someObject)
   End Using


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
8/8/2008 2:02:39 PM
Reply:

Similar Artilces:

OnActivateView problem
I have a class derived from CView, say CViewA. I have controls in a CDialogBar. when the view CViewA is activated I enable the button on the dialogbar and when it is deactivated I disable the buttons on the dialog bar. But i donot want the buttons to enable or disable when there is switch between same type of view. This is creating refreshing problem. First the CViewA, OnActivateView is called with bActivate equal to False, then the same function is called with bActivate equals to true. I used the following code to find which view is getting active:- CMainFrame *frame = (CMainFrame *)AfxGet...

Problems sharing a file
I'm running Excel 97 SR2 and Win98SE. When I share the workbook Excel wants to save the book. OK. It then notifies me that it contains macros & VB code ... OK. I then get an illegal operation message and it closes Excel without saving. When I open the file again, sharing is not enabled. Did I miss something? Anyone have any ideas on what is wrong? Oscar ...

Microsoft Offide for Mac 2004 Causes Sleep Problem
After installing the latest update for Office for Mac 2004, my G4 will not fall asleep automatically according to the setting in System Preferences. I can put it to sleep manually, but since I don't always know when I am not coming back to the computer for awhile, this is an issue for me. Can anyone help? Is it possible to uninstall this update, or would it involve uninstalling all the Office apps and starting over? I sure hope not. H.G. On 5/28/07 5:34 PM, in article 1180398840.085234.35540@q69g2000hsb.googlegroups.com, "CALF@swbell.net" <CALF@swbell.net> wrote: > A...

XmlValidatingReader invalid xsi:type
I have an abstract base class and two derived classes that I want to serialize and deserialize with schema validation. When I serialize instances of the derived classes the XmlSerializer adds the xsi:type="DerivedClass" attribute and the Instance Namespace. When I attempt to validate the xml upon deserialization the XmlValidatingReader chokes on this attribute value. I can't seem to find a way around this. Any suggestions? Could you post your final XSD and XML you are trying to validate using XmlValidatingReader ? "Jason Cartwright" <jason@cartwrightkids.com> w...

Massive problems after server crash......help..!
Hi, I need to pick as many brains as I can to get me out of a mess. I have just took over as a network manager at a school, Four servers all 2003 and 600 XP Pro workstations.I have not got much experience with exchange 2003. Yesterday the exchange server crashed, I knew I need to have a look at it before but only on my fourth day of work I had not got round to it. Now the server takes a age to reboot and then log on. After about tem minutes the desktop becomes workable. But my problem is that now Exchange manager will not launch. I check the services and all the exchange services are s...

M$ Money 2007 Automatic Software Update Problem...
I'm using MS Money 2007. Whenever I runs it, it says "To operate correctly,click 'ok' to let Money download the software update." But I click ok, it says "A software update is already in progress.Please try again when the update is complete." I never update successfully. Can I disable that useless software update???? Getting the same message but my update runs and says it has completed then prompts again every time I start Money 2007 Home & Business. I spent some considerable time on several Microsoft support chats with no solution. -- Eric Bennett ...

Problem w/email signature on scanned docs.
When we use our printer to scan a document to email, the email that comes up to send will not automatically add the signature that is set to go with mail from that user. Does anyone know if there is a setting I'm missing somewhere? We use Outlook 2003 and an HP LaserJet 3015 printer/scanner/fax. Thank you Pearl King "Pearl King" <paking@kc.rr.com> wrote in message news:e5tHJtuiJHA.956@TK2MSFTNGP05.phx.gbl... > When we use our printer to scan a document to email, the email that comes > up to send will not automatically add the signature that is set to go wi...

Active Sync Problem
I have reset my pocket pc and cannot sync with my PC outlook files. How do I reset the partnership for the pocket device and the PC. The Wizard will only let me connect as a guest because the partneship is not set for the reset pocket. Thank You Mike1590 <Mike1590@discussions.microsoft.com> wrote: > I have reset my pocket pc and cannot sync with my PC outlook files. > How do I reset the partnership for the pocket device and the PC. The > Wizard will only let me connect as a guest because the partneship is > not set for the reset pocket. Thank You Delete the partnership ...

Major problem with XSD schema's in Internet Explorer
We develop and host a webbased accounting application which is fully xml/xsd and webservice oriented. We have recently noticed that xml schemas (xsd or xdr) are not being cached by Internet Explorer, or at least the cache isn't being used anymore. We know for a fact that this was working properly until recently: if-modified-since headers would be sent to the server which then replied with 304's, but now we see that these headers are not being sent anymore, forcing the server to respond with a 200. We suspect it must be due to some recent windows update (urlmon, wininet, msxml ?...

Task request problem
just put in new computor Dell /XP /Office Pro 03 outlook can not open task requests sent from others When trying to open there is a "cant open this item" error or operation failed:an object could not be found all other computors (outlook 00) can open these. I can send a task request that they can open Any help? Thanks Steveo ...

Roles/Security Problems
Hi Still using good old V1.2 and having problems with setting up roles and security for 'hiding' information between two different business units. Reading all the documentation on roles/security it all seems so easy but it does not seem too be working for us! I have two business units Sales and Purchasing, each with a user role set to only read/write/delete etc within the business unit. Now, I create a contact using a login within the purchasing BU but a sales user can still see it..... Any ideas? In urgent need to resolve this before getting the purchasing department onl...

Help help ,help! OWA problem. 440 Login Timeout https://emilserver/exchweb/bin/auth/owalogon.asp?url=https://emailserver/exchange&reason=0
I installed Exchange2003 in windows 2003 server. it runs well . but few days ago, when I using https://emailserver/exchange to access OWA it automatic change address to https://emilserver/exchweb/bin/auth/owalogon.asp?url=https://emailserver/exchange&reason=0 and display below: 440 login Timeout. exchange2003 other part is good. user can use POP3 and SMTP. so I don't wan't reinstall all exchange2003 . I need find a tools or some thing can reinstall or reset OWA in IIS . who can help me? Thanks A lot. Best Regards Jeff Does this help? http://msmvps.com/cgross/archive/2004/0...

sent to problem
When I go into my documents and right click on a word doc and select send to mail recipient Outlook express would try to open up and configure even though I am using outlook on an exchange 2k3 platform. I removed outlook express but now it does nothing when I select the send to mail recipient. Any suggestions on how to mail outlook 2k3 the default would be appreciated. In ie 7 I have outlook selected as I can send pages through outlook from ie but not when I right click on a word doc - or any file and select the send to command ...

HD problem
A few days ago my backup software wouldn't work, it gave a message: "Failed to read from the sector 63 of hard disk". I ran Windows Chkdsk and it found no problems. The software worked until three days later and it had the same problem. I ran Chkdsk again, still found no problems. Then it worked again until two days later, when I got the same message. Is the HD about to go bad? Will formatting it help? Or it is time to get a new HD before it dies? -- Replace you know what by j to email Jan Philips wrote: > A few days ago my backup software wouldn't w...

unsolvable problem
This the first time I've posted a message, left it up for a week and received no replies. My unsolvable problem is mail I send from Outlook or Outlook Express is sent BUT also stays stuck in my outbox with the message that it has not been sent. ...

moving Dialog problem
I make maximize dialog used 'ShowWindow(SW_MAXIMIZE)'. and void CEds1000_3Dlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(){ AfxGetMainWnd()->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y)); //moving dialog } CDialog::OnLButtonDown(nFlags, point); } but maximize dialog move, too. I want to don't move the maximize dialog. I dont understand how a maximized dialog is being moved by default. It should not. You should not need to handle OnLButtonDown. -- Ajay Kalra [MVP - VC++] ...

Outlook contact list problems
I cannot load the exchange contact list with outlook 2003. Since i have installed this version of outlook, i have a POP UP windows every time i push TO: button to get the exchange 2000 contact list from my domain The windows says that i cannot find the LDAP server I tried all the DC servers and i still having this problem, i cannot see the exchange contact list Please hel Dioxido dioxido <dioxido@sinectis.com.ar> wrote: > I cannot load the exchange contact list with outlook 2003. Since i > have installed this version of outlook, i have a POP UP windows every > time i push TO: ...

Save All Attachments
Periodically, I get emails with several *.txt files attached (I am using Outlook 2000). Instead of saving the attachments one file at a time, I have tried to chose all the attachments, then save all of them. Sometimes this works well, and other times, I get the message that "The filename is not valid." Its like if I navigate to certain folders, it doesn't work but there is no real "weirdness" related to the folder name that I see. Does anyone know what's going on here? Is there some kind of limitation to the length of the path and file name? Any help appreciat...

setting xsi:schemaLocation on XmlSerialize
I'm developing a GUI application in C#. I have a schema file (.XSD) and am able to serialize and deserialize the applications data using the schema file to an .XML file. (I'm using xsd.exe to generate my serializable class, XmlSerializer to Serialize and DeSerialize and XMLValidatingReader to validate. My intention is that application users can edit the content of the .XML file using their favorite XML editor as well as by using my app. However I want the user's XML editor to be aware of my .XSD file. In a previous posting Priya Lakshminarayanan pointed out that, wi...

Problem syncing to device
I've recently encountered a problem syncing mp3 music files from my computer to my mp3 device (this computer had been syncing perfectly well until about a week ago). The sync results appear successful in WMP. But when I unplug the device and try to play, the device doesn't recognize virtually any track info (genre, album title, artist) and the song won't play. This isn't any issue with the device, as I've successfully sync'd today using a different computer. Any thoughts on what's going on with WMP (version 11) and how to resolve this? In WMP,open t...

GP GL recurring entry problem!
hi, I have created the prepayment batch which will recur 11 times monthly in general ledger, this expenditure occurred starting from Aug, been posted on Nov..however, after posting it, there is just Aug expenditure bumped up while same journal no. showed two entries, which are duplicated and one of that is showing the audit trial code, the other one remains original journal no. and batch no.; also, the other prepayment batch i created recurring 3 months, it did show the aug and sep expenditures, however the oct expenditure can't be showed up after post. Linking with this two ...

Problem with CTabCtrl
I've got function which add CPropertyPage to CPropertySheet. void addPage(CPropertyPage * my_new) { m_startSheet->AddPage(my_new); index = m_startSheet->GetPageIndex(my_new); CTabCtrl * pTab_p = m_startSheet->GetTabControl(); CString s = "Blablabla"; TC_ITEM ti_p; ::ZeroMemory(&ti_p, sizeof(ti_p)); char szText_p[100]; ti_p.mask = TCIF_TEXT; ti_p.pszText = szText_p; ti_p.cchTextMax=100; strcpy(szText_p,s);//problem !!!!!!!!!!!!!! VERIFY(pTab_p->SetItem(indeks,&ti_p)); //problem !!!!!!!!!!!!!! } An...

Edate problems
I am having problems wtih getting the correct date. My start date is 03/12/06 in cell C4 and I want to calculate 6 calendar months from that date into another cell. All I end up with is 09/12/06, when it should be done in regular calendar months. The answer should be 09/21/06 but I don't know how to get the formula to get that date. I tried using just the date function and then tried edate function. Please help By what criteria should 6 months on from 12 Mar 2006 be 21 Sep 2006? -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Jodi&quo...

Margin printing problem
I'm trying to print a document and it keeps cutting off a tiny part of the right side of my document. I have equal margins on the right and left and it has no problem printing to the left side where it should. I'm not trying to print borderless. I have my layout guides at .27. I'm using an HP 1200 and my printer drivers are up to date. Am I just stuck here because of this printer?? Is there anything else I can try? Thanks. The HP site says you should be able to print within the margins you have specified. Open WordPad, file, page setup, input zero into each margin, ...

CEdit problem
Hi experts, I m preparing Excel kind of thing using SDI application. I m using CEdit object for entering text. I have kept the size of CEdit as the size of my cell(D5 etc..) What i see is that inside my edit Box the text are displayed in bold letters. I dont want this. Moreever after reaching the limit of edit box i should dynamically increase the edit box's size while typing, as needed. See Microsoft Office Excel 2007 (Beta) for further checking.. Can any one of u guide me to how to do this???? Thanks To get rid of bold font, you should change the font to whatever you want(use SetFont)...