XML <-> object mapping tool?

Hi;

I have a small XML file that I need to read/change from my app. Is
there some easy way to map from XML to my objects so I can just read
it in to my objects, change the objects as needed, then write the
whole thing back out?

thanks - dave

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
0
thielen (152)
9/25/2008 3:12:53 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
754 Views

Similar Articles

[PageSpeed] 32

Hi Dave,

As for mapping object and xml document, the first thing I can get is the 
XMLSerialization, which is the dedicated technique in .NET framework for 
class /XML mapping. If the xml schema is not quite complex, you can 
directly define the .net class(with XML serialization attributes) or use 
the XSD.exe tool to generate the class code from xml file(or xsd schema):

#XML Serialization in .NET
http://www.codeproject.com/KB/XML/xmlserialize.aspx

#XML Serialization in the .NET Framework
http://msdn.microsoft.com/en-us/library/ms950721.aspx

#XML Schema Definition Tool (Xsd.exe)
http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.71).aspx

also, with LINQ appearing, it is also very convenient to use LINQ2XML to 
manipulate XML document, do some transforming(to different xml format or to 
..NET class objects..) especially when you use VB.NET:

http://www.codeproject.com/KB/linq/LINQtoXML.aspx

http://blogs.msdn.com/xmlteam/archive/2007/03/03/the-new-linq-to-xml-bridge-
classes-to-system-xml.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
>From: David Thielen <thielen@nospam.nospam>
>Subject: XML <-> object mapping tool?
>Date: Wed, 24 Sep 2008 21:12:53 -0600

>Hi;
>
>I have a small XML file that I need to read/change from my app. Is
>there some easy way to map from XML to my objects so I can just read
>it in to my objects, change the objects as needed, then write the
>whole thing back out?
>
>thanks - dave
>
>david@at-at-at@windward.dot.dot.net
>Windward Reports -- http://www.WindwardReports.com
>me -- http://dave.thielen.com
>
>Cubicle Wars - http://www.windwardreports.com/film.htm
>

0
stcheng1 (64)
9/25/2008 5:08:18 AM
Hi David,

If a tool then Liquid, Castor.net, and so on. take a look at http://www.thehtmltag.com/databinding.html 
or http://www.byteslooser.com/csharp/xmlobjects/
Relatively easy way is de/serialization (with a combination of LINQ).

Regards, Alex Meleta
mailto:ameleta@gmail.com; blog:devkids.blogspot.com

> Hi;
> 
> I have a small XML file that I need to read/change from my app. Is
> there some easy way to map from XML to my objects so I can just read
> it in to my objects, change the objects as needed, then write the
> whole thing back out?
> 
> thanks - dave
> 
> david@at-at-at@windward.dot.dot.net
> Windward Reports -- http://www.WindwardReports.com
> me -- http://dave.thielen.com
> Cubicle Wars - http://www.windwardreports.com/film.htm
> 


0
ameleta (7)
9/25/2008 5:14:15 AM
Reply:

Similar Artilces:

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 ...

protect embeded object
Hello, I have a worksheet with an embedded Project file. is it possible to protect the worksheet to not allow users to delete the embedded file, but to allow them to edit the embedded file? thanks Hi don't think this is possible. Maybe create a macro which first unprotects and then opens your object -- Regards Frank Kabel Frankfurt, Germany "greg" <greg@nospam.com> schrieb im Newsbeitrag news:O4dM07i3EHA.1372@TK2MSFTNGP10.phx.gbl... > Hello, > I have a worksheet with an embedded Project file. > is it possible to protect the worksheet to not allow users to del...

Outlook 2000
I have a friend who has Tools missing from his menu bar. Can anyone help on how to get it back? Barry Restore the menu bars, see "Restore Any Toolbar" http://www.officearticles.com/misc/menu_and_toolbar_tips_for_all_microsoft_office_applications.htm ******************* ~Anne Troy www.OfficeArticles.com "Oldmoondog" <oldmoondog@ntlworld.com> wrote in message news:18HIe.550$jv2.474@newsfe2-gui.ntli.net... > I have a friend who has Tools missing from his menu bar. Can anyone help on > how to get it back? > Barry > > ...

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...

Tools cease working
Frequently my font size tool, percent tool, and currency tools on the Formatting toolbar stops working. It has no action. Other times it works. Anyone know anything about this problem before I work to establishing a pattern? Excel 2002 SP2 Windows XP Thanks. It could be a bad xlb file. Search for *.xlb and move the found files somewhere else. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "c mateland" <chuckmateland@yahoo.com> wrote in message news:1151720769.895348.319380@d30g2000cwa.googlegroups.com... > Frequ...

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 ...

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...

outlook 2000 mailbox.pst error. inbox repair tool
hi all I am getting a error message from outlook 2000 that says errors have been detected in the file c:\windows\application data\microsoft\outlook\mailbox.pst It says to use the inbox repair tool. I have searced microsoft online help and found the site "ol2000 how to find and run the inbox repair tool" I am using ME. I have been looking for "Scanpst.exe" file. Microsoft help says to follow c:\program files\common\system\Mapi\1033\nt I cannnot find a file by this name. I can find a file c:\program files\common\system\Mapi\1033\95 when I run "Scanpst.exe&qu...

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...

message between objects.
I have designed a class CA and there is a message queue in the class. i.e. Class CA { .... queue q; } Then, i defined two variables: CA a1; CA a2; I am execpting that a1 can send a message into a2's queue. What should I do in the Class CA design?Thank you very much for yoru suggestions -- Best Regards Yan ZHANG http://www.nict.com.sg/zhang/ "Yan ZHANG" wrote: > I have designed a class CA and there is a message queue in the class. i.e. > > Class CA > { > .... > queue q; > > } > > Then, i defined two variables: > > CA ...

Object Reqired Error Using Kill
I use an ocx in a form, but I want to delete the ocx before the program ends. So, I unload the form and try to execute the instruction Kill My.ocx. But, I get an Error 424 "Object required" error. Is it impossible to delete an ocx that was used at any time in an app even if the form where it was used no longer exists? jim evans wrote: > I use an ocx in a form, but I want to delete the ocx before the > program ends. So, I unload the form and try to execute the > instruction Kill My.ocx. But, I get an Error 424 "Object required" > error. Is it impo...

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/ ...

Multi threading / synchronization object
Hi, I have a library as a dll and I need to load this in multi threaded application .(More than one thread in a process and more than one process). How can I snchronize the comman resources among thread and process( ie data base, shared memory etc). Which synchroniztion method should I use and why should I use that( Mutex,Semaphore,Event or Critical section.) If any one can tell which is the best and why , it will be highly appreciated. Thanks and Regards RGP Rinu Gopalakrishna Pillai wrote: > Hi, > > I have a library as a dll and I need to load this in multi thread...

String to xml document
Hi there, I was hoping someone can help me with a little problem I can't seem to find any answers to. I've got a form wich will be posted. On receiving the post I would like to parse a formvar to a xml document. The contents of this formvar (string) will be a valid xhtml document. Can someone give me a startertip (or more :-)) on how to achieve this? tnx in advance, James van der Veen Sjeems wrote: > I was hoping someone can help me with a little problem I can't seem to find > any answers to. > > I've got a form wich will be posted. On receiving the p...

Beginner of XML
I am a beginner of XML. I want to group some files together with a xml file. (it includes a text file, and an image file and a video file) Can someone show me some guidelines? Please help. ...

Valid xml to read from an xml file?
I'm using vb.net, i get an error at the reader line saying the remote server can't be found. Is the below even valid? dim reader as XmlTextReader reader = new XmlTextReader ("http://www.mysite.com/my.xml") do while (reader.Read()) 'do some action here response.write(reader) loop thanx chumley XmlTextReader uses System.Net.WebRequest under the covers -- see if you can figure out how to create a connection that way. Usually there's some proxy server information missing that you can enable if you use WebRequest directly, and then pass the result of GetResponse()...

Example eConnect XML documents
MSDN says the following: Installing eConnect schema When you include the schemas component of the eConnect install, the installer places schema files in a schemas folder on your computer. The following schema resources are available: The install places the .xsd schema files in the directory c:\Program Files\Microsoft Great Plains\eConnect9\XML Schema\Incoming XSD Individual Schemas. The files in the directory contain the schema for each eConnect XML document. The install places a file named eConnect.xsd that contains the schema definition for all eConnect XML documents. The install typicall...

How to synchronize fields between objects
We are trying to automate some data entry between an Opportunity and Account objects. We enter data in the Opportunity object and when we close the opportunity with a win, we want to automatically populate equivilant fields in the Account object. The Account already exists, we want to refect the changes made in the opportunity. I have looked at onchange events, but that seems to only allow updates on the same form and I have looked at workflow but again that only allows chagnes within the same object. Any recommendations. Thanks in advance. -- Patrick The way to do thiw would be ...

XML variable for description on receipt?
Hi, I would like to add a description (actually all of those 3 extended descriptions) to display on the printed receipt under the main description. What is the variable to do that? Entry.Item.Description Entry.Item.ExtendedDescription Entry.Item.SubDescription1 Entry.Item.SubDescription2 Entry.Item.SubDescription3 R. "Zorian" <Zorian@discussions.microsoft.com> wrote in message news:F4425EAC-62B6-46FE-826A-D8BA2AA75DBB@microsoft.com... > Hi, I would like to add a description (actually all of those 3 extended > descriptions) to display on the printed receipt un...

Visual Studio Tools #2
Hi All I am using visual studio 2005 and microsoft dynamics 9.0 . Is there any way to add the menu under cards or transaction , I mean to say other then the "Extra" menu . I had created the menu using Dexterity under the above mentioned menu . Hi Sandeep At this time Dexterity is the only tool which can create a new menu entry. David Musgrave [MSFT] Senior Development Consultant Escalation Engineer - Great Plains Microsoft Dynamics Support - Asia Pacific Microsoft Dynamics (formerly Microsoft Business Solutions) http://www.microsoft.com/Dynamics mailto:dmusgrav@online.microso...

Saving DataSet as XML in ADO format using VB.NET
Hi, I am trying to convert a lot of web reports from ASP/VB to ASP.NET/VB.NET. I would like to save my dataset in XML and then use XSLT to transform the XML. The catch is I would like to have the XML in the format that ADO uses versus the default format in which ADO.NET uses. Currently, I am using ADO within .NET, but I am concerned about the performance and it might improve if I used the native data providers for .NET. I am not sure if I am missing something but how do I save the .NET DataSet to XML in the OLD ADO format? Thanks for you help in advance and it is most appreciated. In the ...

xml to SQL
Hey we have a project in which a company produces a XML page in reply to actions on it's site. I see that SQL 2000 works well with XML so Can someone point me in the right direction, I would like to take the XML from thier SQL and have it "post" to own sql server (add,create, data, modifity and delete data on the fly). I was looking at doing XML to HTML and then passing to some a ASP but if we can grab from the responsetext then we could save time and headaches. Now I really know next to nothing about XML but I am reading all the newsgroups and pulled now TONS of xml / sql stuff ...

Using the CHtmlView object with Print Preview (ExecWB)
I have a problem. When the user clicks a button on my application, I create a hidden CHtmlView object, export some data as HTML and load it into the browser. This is all done inside my dialogues button message handler. I then want to invoke the print preview using ExecWB but nothing works. I found out that if I post a button click message to another hidden button and do the ExecWB from there that the preview will display. I also found that I must delete and re-create the hidden browser for the preview to synchronize corectly. My problem is that one some computers I am being told that...

new xml file is larger than the original
i'm working on a windows application that will edit and create xml files from another application. the original file is 83k, the one created by my vb.net program is 153k but all i add is a new xmlelement when i use the other program and add a xmlelement is only increased the file to 85k. how come my application increased 70k in size and also added the <?xml version="1.0"?> when i didn't tell it to. how do i duplicated a xml file and only add the xml element that i want to insert. where did the extra 70k come from. thanks here is my code: Dim newEvtEnr...

planner tools
i just imported money files from 2000 to 2005 , and cannot find the debt reduction planner. it is not in the planner tool bar. help says there is a planner tools button , but it is missing..any help? "jim" <jim@discussions.microsoft.com> wrote in message news:29697B61-1749-4ADC-8FE3-64298C012B00@microsoft.com... >i just imported money files from 2000 to 2005 , and cannot find the debt > reduction planner. it is not in the planner tool bar. help says there is a > planner tools button , but it is missing..any help? Standard or Deluxe? I don't know if there's...