Should I seriize xml or I should just leave it as text? thanks

Last time, I asked a question about if a XPathDocument could be serialized.
Actually what I really want to know is how should I do in this case:

I have a class that will be serialized. In the class, I need call another
class, which will read setting from database. I want to load the xml once
and use it in the following calls. So it need to be serialized. But
XPathDocument doesn't support it. What should I do here? make the class
serializable? or put the xml in a string and create XPathDocument in every
call, or othe way?

Thanks!


0
davidw4067 (15)
6/26/2005 5:22:22 AM
dotnet.xml 7266 articles. 0 followers. Follow

5 Replies
537 Views

Similar Articles

[PageSpeed] 13

So I should not use the XPathDocument, how should I store those settings?
should I use Hashtable? If I only need some data in the settings, isn't it a
bad idea to parse all data from XML string to Hashtable?


"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:uxILizieFHA.1328@TK2MSFTNGP12.phx.gbl...
> davidw wrote:
> > Last time, I asked a question about if a XPathDocument could be
serialized.
> > Actually what I really want to know is how should I do in this case:
> >
> > I have a class that will be serialized. In the class, I need call
another
> > class, which will read setting from database. I want to load the xml
once
> > and use it in the following calls. So it need to be serialized. But
> > XPathDocument doesn't support it. What should I do here? make the class
> > serializable? or put the xml in a string and create XPathDocument in
every
> > call, or othe way?
>
> Create a serializable class for your settings and use it instead of
> XPathDocument.
>
> -- 
> Oleg Tkachenko [XML MVP, MCAD]
> http://blog.tkachenko.com


0
davidw4067 (15)
6/26/2005 9:09:29 AM
davidw wrote:
> Last time, I asked a question about if a XPathDocument could be serialized.
> Actually what I really want to know is how should I do in this case:
> 
> I have a class that will be serialized. In the class, I need call another
> class, which will read setting from database. I want to load the xml once
> and use it in the following calls. So it need to be serialized. But
> XPathDocument doesn't support it. What should I do here? make the class
> serializable? or put the xml in a string and create XPathDocument in every
> call, or othe way?

Create a serializable class for your settings and use it instead of 
XPathDocument.

-- 
Oleg Tkachenko [XML MVP, MCAD]
http://blog.tkachenko.com
0
Oleg
6/26/2005 9:57:33 AM
davidw wrote:
> So I should not use the XPathDocument, how should I store those settings?
> should I use Hashtable? If I only need some data in the settings, isn't it a
> bad idea to parse all data from XML string to Hashtable?

Well, I meant not Hashtable, but domain-specific class with meaningful 
properties for settings:

public class MySettings {
   public string ReportWidth {
	get { return ...}
         set { .....}
   }
   ...
}

-- 
Oleg Tkachenko [XML MVP, MCAD]
http://blog.tkachenko.com
0
Oleg
6/26/2005 10:22:01 AM
Right, but where should I store the setting data, I need load the data from
DB and store it in an object in the class and access it when the class is
called to get a specific setting. I don't want access DB for each setting,
does that make sense?

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:OwObOBjeFHA.3712@TK2MSFTNGP12.phx.gbl...
> davidw wrote:
> > So I should not use the XPathDocument, how should I store those
settings?
> > should I use Hashtable? If I only need some data in the settings, isn't
it a
> > bad idea to parse all data from XML string to Hashtable?
>
> Well, I meant not Hashtable, but domain-specific class with meaningful
> properties for settings:
>
> public class MySettings {
>    public string ReportWidth {
> get { return ...}
>          set { .....}
>    }
>    ...
> }
>
> -- 
> Oleg Tkachenko [XML MVP, MCAD]
> http://blog.tkachenko.com


0
davidw4067 (15)
6/27/2005 4:33:09 AM
davidw wrote:
> Right, but where should I store the setting data, I need load the data from
> DB and store it in an object in the class and access it when the class is
> called to get a specific setting. I don't want access DB for each setting,
> does that make sense?

Sure. Load you settings from DB and populate your settings instance. You 
can do it in a number of ways - manually, via serialization, etc.

-- 
Oleg Tkachenko [XML MVP, MCAD]
http://blog.tkachenko.com
0
Oleg
6/27/2005 9:48:14 AM
Reply:

Similar Artilces:

XML to XML Using XSLT
Hi, I need to transform one xml document into a second xml document. They both have many nodes so xslt works fine, but there is one node I have not figure out how to transform. Here it is: Node in Input File. <FullAddress>JOHN SMITH@19495 BISCAYNE BLVD@MIAMI@FL/33180@USA</FullAddress> The Result should be: <Name>JOHN SMITH</Name> <Address>19495 BISCAYNE BLVD</Address> <City>MIAMI</City> <State>FL</State> <ZipCode>33180</ZipCode> <Country>USA</Country> It seems to me I have to "Split" or "Par...

Excel to XML #2
'Is there a converter for Microsoft Excel 2000 files that will save the files as .xml'. File, Save As the file extension is still .htm or .html -- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "MS" <msamant@drvc.org> wrote in message news:6d9a01c475a9$0dbed6f0$a501280a@phx.gbl... > 'Is there a converter for Microsoft Excel 2000 files that > will save the files as .xml'. ...

Help text for fields...
Hello, how can I create a help text for a field in a crmform? --Label--------------------------------- | | | fieldname1 [Textbox1] description | | fieldname2 [Textbox2] of the value | | fieldname3 [Textbox3] in the box | |________________________________| I need descriptions for each value in a picklist or a textbox. But how can I create "HTML Text"? Did you know a other way to describe this? Thanks, Stefan You could use an iframe to show a custom html page and design the custom page to look like par...

Excel 2000 XML
Crazy question: does anyone have any documentation on the XML spreadsheet schema for Excel 2000? The links to it on the Microsoft support site are bad, and it changed in version 2002. (Here's a link to the 2002 version: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xmlss.asp.) Many thanks! Sharon ...

Why is message text deleted in some replies?
Since starting using Outlook two days ago, and sending several messages and receiving replies, two of the replies to messages showed only my original message without the text of the reply. By phone I got one of the recipients to re-send several times while I (a) turned off the junk mail filter (b) turned off the firewall (c) turned off antivirus, all to no avail -- I still only see my original message and not their reply. "PhineasP" wrote: > Since starting using Outlook two days ago, and sending several messages and > receiving replies, two of the replies to messages ...

Compress and secure XML?
Hi! This is a situation who can happen often and I would like to know if something exist. I try to create an application who use XML as a native database. The problem is that I don't want that the user can play in the XML. I would like to compress the file and encrypt so to block the user. The goal is to have a class that can read directly in the file (compressed and encrypted) as a normal XML document and can not be read in an editor. I know that it's possible to do that seperatly but the performance is touched. Sometime it has company or people who has done it as super performant ...

How do you insert a title above 2 columns of text?
I need to center a title above 2 columns of text . It will only center above the first column. Help. The quickest and easiest imo is to use a text box. Then you can put the heading where ever you would like and it won't interfere with the formatting on the page. Or you can use the header section of the document. hope this helps. RC "Taylor" wrote: > I need to center a title above 2 columns of text . It will only center above > the first column. Help. Select the entire paragraph containing the title, go to the Columns dialog, and choose one column....

xml resource cleanup?
I have the following code: // code start string resultValue; XmlTextReader xtReader = new XmlTextReader(dataXml, XmlNodeType.Element, null); XPathDocument xpDoc = new XPathDocument(xtReader); XPathNodeIterator iterator = xpDoc.CreateNavigator().Select("//result"); while(iterator.MoveNext()) { resultValue = iterator.Current.Value; break; } return resultValue; // code end Is there something that I can do to help clean up any resources right away or do I just wait for the GC? Jiho Han wrote: > I have the following code: > > // code start > string resultValue; ...

XML formatter
Hello, I developed an VC++/MFC application that creates an XML file. It creates the file correctly, but the file is one long text string (no CR/LF, no indentation,...). Can anyone recommend some source code (hopefully FREE, but will pay for the source code) that can take the XML file an "pretty" format the data? TIA, Jacques Jacques, I might be dense, but why don't you format the XML yourself, when you save it to file? Johan Rosengren Abstrakt Mekanik AB "Jacques Cooper" <jcooper@jcsoftware.net> a �crit dans le message de news:%23FOkiWTwDHA.1908@TK2MSFTNG...

Advanced XML Creation using Helper class created by XSD.EXE from a schema
I'm going to paste the section of the helper class below. What I can't figure out is really what is required or how to set the value for the item - Identification which is of type PharmacyID. Language is C#. Here's my code attempt and where I'm stuck: PharmacyIDType ID = new PharmacyIDType(); ItemsChoiceType it = new ItemsChoiceType(); // choicetype? // it. in the editor doesn't give me any options to set a value - only a name // ID. offers an ItemsElementName which I will set to "it" and is of ItemsCho...

save as a text file
I've got a weird one here! When attempting to save an email (or multiple emails) to a text file, 2 computers in my office will save the to, from and subject lines as well as the email body but 2 others will only save the to, from and subject lines! I need all computers to save files with the email body! All computers are using Outlook 2003. I can not find any reason why these machines will not save the body. Can someone please help me?! Scott The ones not working are either at a lower service pack level or are using an ANSI pst (old format). -- Diane Poremsky [MVP - Outlook] Author, ...

thanks
thanks a lot buddy.Bye. ...

Should I seriize xml or I should just leave it as text? thanks
Last time, I asked a question about if a XPathDocument could be serialized. Actually what I really want to know is how should I do in this case: I have a class that will be serialized. In the class, I need call another class, which will read setting from database. I want to load the xml once and use it in the following calls. So it need to be serialized. But XPathDocument doesn't support it. What should I do here? make the class serializable? or put the xml in a string and create XPathDocument in every call, or othe way? Thanks! So I should not use the XPathDocument, how should I stor...

Importing external data in plain text row format
I have data in the following format: -------------------Begin Sample Data---------------------- Fernando E. Amuchastegui Office of the County Attorney 115 S. Andrews Avenue Suite 423 Fort Lauderdale 33301 954-357-7600 Voice 954-357-7641 Fax famuchastegui@broward.org Ronald J. Anania Law Offices of Ronald J. Anania 10910 S W 10th Court Davie 33324 954-476-9616 Voice 954-476-9693 Fax law1492aol.com Eric J. Anders Haley Sinagra Paul & Toland, P.A. 100 SE 3 Avenue Suite 1900 Fort Lauderdale 33394 954-467-1300 Voice 954-467-1372 Fax eanders@hsptlaw.com Hal B. Anderson Billing Cochran H...

floating comments or text boxes
is there a way to keep a comment or a graphic that "floats" above th spreadsheet, so when you scroll down the box(or image) stays there, an the sheet scrolls down? (kind of like how the ofice assistant is, onl i have a company logo that i want visible at all times. -- Message posted from http://www.ExcelForum.com You can put your logo at the top of the sheet, split the window and se to "freeze" the top rows (and/or columns) -- Message posted from http://www.ExcelForum.com ...

XML Header
Hi, I have some XML doc loaded in a C# Web Service. XmlDocument doc = new XmlDocument(); doc.LoadXml(myDoc); Code Missing to manipulate header (I would like to replace or manupulate all these XXXXX): <mso-XXXXXX productversion="XXXXXX"> <mso-application progid="XXXXX"?> doc.Save(myNewDoc); Any idea on how to access and manipulate data within the doc header? Thanks vbdev vb6dev2003 wrote: > I have some XML doc loaded in a C# Web Service. > XmlDocument doc = new XmlDocument(); > doc.LoadXml(myDoc); > > Code Missing to manipulate header ...

Read XHTML into XML
Hi all, I need to read/parse XHTML aspx pages and look for certain tokens and content. How can I use a XmlTextReader for this? If not, any other ideas? Thanks in advance, JA Reyes. Jose Antonio Reyes wrote: > I need to read/parse XHTML aspx pages and look for certain tokens and > content. How can I use a XmlTextReader for this? If not, any other ideas? If the pages are well-formed XHTML then it is possible to use XmlReader (in .NET 2.0/3.0) or XmlTextReader (in .NET 1.x) to parse the XHTML documents. You can also use the other XML APIs .NET provides so using XPathNavigator and/o...

How to invoke the xml editor?
I installed vs2005 on a new xp pro machine, and installed everything except C++. When I click on a file with a ".xml" extension it is opened with IE. When I click file/Edit with XML Editor, it opens it with Notepad. If I click File/Open With and select XML Editor, it opens it with IE. So, where is the xml editor? Can it be invoked from withing VS? Where? Bill * billsahiker@yahoo.com wrote in microsoft.public.dotnet.xml: >I installed vs2005 on a new xp pro machine, and installed everything >except C++. When I click on a file with a ".xml" extension it is >opened ...

how do i hyphenate text in excel
how do I edit narrative entries in an excel spreadsheet format? I.e. how do I get words to hyphenate automatically in cells? XL isn't a word processor - there's no built-in functionality for automatic hyphenation. XL knows nothing about words, punctuation, etc. In theory it could be done with event macros, but if you're looking for hyphenation at syllabic borders, they would have to be rather sophisticated. In article <259E5311-F66B-4DDD-BAE5-87E40D39A625@microsoft.com>, cjol in WA <cjol in WA@discussions.microsoft.com> wrote: > how do I edit narrative ent...

show XML schema and values
I have an XML document that looks like the following: <record> <Field1>value1</Field1> <Field2>value2</Field2> <Field3>value3</Field3> </record> What I'm aiming to do is to show the data in a report as in the following example: record: Field1 value1 Field2 value2 Field3 value3 The "Field1-3"-elements can have any name, so I'm trying to get a table that has in one result column the element name, and in the second colum...

Offline synch using XML web-services
This is a bit long-winded. Can somebody read thru these 2 use cases, and tell me if it is feasible ? :- Use Case : Replication before Offline Synch Scenario 1 : Oracle Server , MSDE client 1. User clicks on 'Go Offline'. System creates a MSDE SQL database in laptop (client), gets the schemas of the tables in Oracle, creates corresponding tables in client's MSDE SQL (mapping Oracle datatypes to SQL datatypes). 2. Offline replication program reads in the tables of the server into a typed datasets, converts the typed datasets into XML, and stores the XML in the client. (XML serial...

Text formatting ?
Hi all, this is kind of embarrassing but one of the directors here at the company, the only person using Outlook 2003 actually, has a problem with composing text in Outlook. up until recently whenevber he typed :) it would change into a smiley face but it no longer does this (as of a week ago) so I chacked the email format and it is HTML... changed it to RTF and Plain text but still no joy. Can anyone assist me in resolving this problem. Thanks in advance, Mitch... Is he still using Word as his email editor? I think that only works when you're using Word "VegaLA"...

Text Formula Question
In COL A, I have a list of 2 and 3 digit charactors. I would like to seperate each string into the three adjacent columns. KQ AJs TT 89s KQ K Q AJs A J s TT T T 89s 8 9 s I know that I can use the Left function for the first col, but cant figure out how to get just the middle or third letters. Thanks in advance, Andrew Check your last post! -- Regards, RD --------------------------------------------------------------------------- Please keep all correspondence within the NewsGroup, so all may benefit ! ------------------------------------------------...

How do I set up a formula to insert text in excel?
Hi, I have a questionnaire that is administered on an excel sheet with respondents typing their answers (i.e 1,2,3) into specific cells. Is there any way that I can create a formula (or something??) that inserts response relevant text into another sheet in the workbook, to create a report? Many Thanks, Nikki Nikki You can use formulas for this type of thing if you want this done only once. But if this is a repeating task I would suggest an event macro. If you want to use an event macro you will have to decide when you want this copying to take place. IOW, what event do you want t...

XML Serialization ... how to truncate <?xml...
While xml serializing object how can I truncate <?xml ...?> this line alone? I need to send the serialized xml data to a web method ... since SOAP already have <?xml tag there was some confusion Any help would be greatly appreciated Thank you Regards Raj Raj wrote: > While xml serializing object how can I truncate <?xml ...?> this line alone? Serialize to an XmlWriter created with XmlWriterSettings where you set OmitXmlDeclaration to true. -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ ...