Can someone point me in the right direction? I need to wrap some class
properties into XML tags in C#. I just need the XML tags and not the XML
document information.
Thanks. 7 1281
Someone else chime in if I am pointing him in the wrong direction,
from what your describing it sounds like reflection is what you need to
use.
mn_ms_user wrote:
Can someone point me in the right direction? I need to wrap some class
properties into XML tags in C#. I just need the XML tags and not the XML
document information.
Thanks.
I'm rather new to reflection, and it is a pretty big namespace. Any idea how
I would accomplish this?
Thanks
"Sean Chambers" wrote:
Someone else chime in if I am pointing him in the wrong direction,
from what your describing it sounds like reflection is what you need to
use.
mn_ms_user wrote:
Can someone point me in the right direction? I need to wrap some class
properties into XML tags in C#. I just need the XML tags and not the XML
document information.
Thanks.
Heres a link to get started: http://msdn2.microsoft.com/en-us/library/cet5e4fx.aspx
mn_ms_user wrote:
I'm rather new to reflection, and it is a pretty big namespace. Any idea how
I would accomplish this?
Thanks
"Sean Chambers" wrote:
Someone else chime in if I am pointing him in the wrong direction,
from what your describing it sounds like reflection is what you need to
use.
mn_ms_user wrote:
Can someone point me in the right direction? I need to wrap some class
properties into XML tags in C#. I just need the XML tags and not the XML
document information.
>
>
Thanks.
You know, after reading some about reflection I realized I might have worded
my initial question wrong. I appologize, but this is basically what I need
(and after some thinking I might just do this with a stringbuilder).
I need to take the values of my class (let's say it's a person class with
properties like FirstName, LastName, Address, City, State, ZIP, etc..) and I
need to wrap these in XML tags like
<Person><FirstName></FirstName><LastName></LastName><Address></Address>.....</Person>.
I wan't sure if there was a quick way to do this with the built in XML
features, like a ToXML() method.
Sorry for the confusion.
"Sean Chambers" wrote:
Heres a link to get started:
http://msdn2.microsoft.com/en-us/library/cet5e4fx.aspx
mn_ms_user wrote:
I'm rather new to reflection, and it is a pretty big namespace. Any idea how
I would accomplish this?
Thanks
"Sean Chambers" wrote:
Someone else chime in if I am pointing him in the wrong direction,
>
from what your describing it sounds like reflection is what you need to
use.
>
mn_ms_user wrote:
Can someone point me in the right direction? I need to wrap some class
properties into XML tags in C#. I just need the XML tags and not the XML
document information.
Thanks.
>
>
Are you pulling the data from a database?
If so, alot of databases allow you to select "AS XML". SQL Server in
peticular has alot of XML based features.
You can tell SQL to selected specific records and return it in xml
format with the results wrapped like you described.
If the data is within your objects and not SQL, you would make a blank
xml file, like you did below, and then hydrate the xml file with data.
if you need some sample code, take a look System.Xml namespace for
methods to perform this. Sorry i dont know any off hand, it has been
awhile since I had to do anything like that.
mn_ms_user wrote:
You know, after reading some about reflection I realized I might have worded
my initial question wrong. I appologize, but this is basically what I need
(and after some thinking I might just do this with a stringbuilder).
I need to take the values of my class (let's say it's a person class with
properties like FirstName, LastName, Address, City, State, ZIP, etc..) and I
need to wrap these in XML tags like
<Person><FirstName></FirstName><LastName></LastName><Address></Address>.....</Person>.
I wan't sure if there was a quick way to do this with the built in XML
features, like a ToXML() method.
Sorry for the confusion.
"Sean Chambers" wrote:
Heres a link to get started: http://msdn2.microsoft.com/en-us/library/cet5e4fx.aspx
mn_ms_user wrote:
I'm rather new to reflection, and it is a pretty big namespace. Any idea how
I would accomplish this?
>
Thanks
>
"Sean Chambers" wrote:
>
Someone else chime in if I am pointing him in the wrong direction,
from what your describing it sounds like reflection is what you need to
use.
mn_ms_user wrote:
Can someone point me in the right direction? I need to wrap some class
properties into XML tags in C#. I just need the XML tags and not the XML
document information.
>
>
Thanks.
Thanks Sean. After more reading, I think I could use customized serialization
to do what I need (although it might actually be easier to use a string
builder and manually build the tags).
Thanks for your replies.
Cheers.
"Sean Chambers" wrote:
Are you pulling the data from a database?
If so, alot of databases allow you to select "AS XML". SQL Server in
peticular has alot of XML based features.
You can tell SQL to selected specific records and return it in xml
format with the results wrapped like you described.
If the data is within your objects and not SQL, you would make a blank
xml file, like you did below, and then hydrate the xml file with data.
if you need some sample code, take a look System.Xml namespace for
methods to perform this. Sorry i dont know any off hand, it has been
awhile since I had to do anything like that.
mn_ms_user wrote:
You know, after reading some about reflection I realized I might have worded
my initial question wrong. I appologize, but this is basically what I need
(and after some thinking I might just do this with a stringbuilder).
I need to take the values of my class (let's say it's a person class with
properties like FirstName, LastName, Address, City, State, ZIP, etc..) and I
need to wrap these in XML tags like
<Person><FirstName></FirstName><LastName></LastName><Address></Address>.....</Person>.
I wan't sure if there was a quick way to do this with the built in XML
features, like a ToXML() method.
Sorry for the confusion.
"Sean Chambers" wrote:
Heres a link to get started:
> http://msdn2.microsoft.com/en-us/library/cet5e4fx.aspx
>
mn_ms_user wrote:
I'm rather new to reflection, and it is a pretty big namespace. Any idea how
I would accomplish this?
Thanks
"Sean Chambers" wrote:
Someone else chime in if I am pointing him in the wrong direction,
>
from what your describing it sounds like reflection is what you need to
use.
>
mn_ms_user wrote:
Can someone point me in the right direction? I need to wrap some class
properties into XML tags in C#. I just need the XML tags and not the XML
document information.
Thanks.
>
>
>
>
mn_ms_user wrote:
Thanks Sean. After more reading, I think I could use customized serialization
to do what I need (although it might actually be easier to use a string
builder and manually build the tags).
You just need to make your class Serializable and use the XmlElement
and XmlAttribute attributes to control how each property if serialized.
using System.Xml.Serialization;
[Serializable]
public class MyClass
{
private int _ id;
private string _firstName;
[XmlElement("FirstName")]
public string FirstName
{
//property code here
}
[XmlAttribute("Id")]
public int Id
{
//property code here
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
URL: http://valsignalandet.com/cookiegrab.php?name=valIdentifier
This page produces a cookie value and sends it back as HTML using PHP
and Javascript to obtain it. This URL will be used as the...
|
by: chotiwallah |
last post by:
i have a little database driven content managment system. people can
load up html-docs. some of them use ms word as their html-editor,
which resultes in loads of "class" and "style" attributes -...
|
by: Jon Slaughter |
last post by:
I have a class that is basicaly duplicated throughout several files with
only members names changing according to the class name yet with virtually
the exact same coding going on.
e.g.
class...
|
by: Tappy Tibbons |
last post by:
I have a class I am serializing, and need the resultant XML to skip/omit
classes that are not initialized, or their member variables have not been
set. Is this possible?
Say for the following...
|
by: Buddy Ackerman |
last post by:
I created this class
Public Class HTMLFileInput : Inherits System.Web.UI.HtmlControls.HtmlInputFile
Public Property Data As String
Get
Return ViewState("HTMLFileInput.Data")
End Get
Set...
|
by: Rob T |
last post by:
OK....trivial question, but would be nice to have....:
Let's say I have simple class like this:
Public Class EMailer
Public As String ' The Internet address of the recipient
Public From As...
|
by: Robert Dufour |
last post by:
Here's the class code snippet
Imports System.Configuration.ConfigurationManager
Public Class Class1
Public _strTestSetting As String
Public Sub SetTestsetting()
|
by: Big Bill |
last post by:
What I have to do is replace some h1 tags with basic p tags but the
end appearance has to be the same. I'm thinking, where I have
<H1>yada</H1>
I can replace it with
<p class="looks like it would...
|
by: shapper |
last post by:
Hello,
I have the following classes:
namespace MyApp.Models {
public class Tie {
public Count Count { get; set; }
public Tie() {
this.Count = new Count();
}
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |