473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Setting attributes XML

Hi to all,

I have just started looking at XML.Serialization classes and would
like to know how I set an attribute for an XML element.

For example, I want my XML doc to look like the following:

<Person>
<Name>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
</Name>
<Address>
<Number>127</Number>
<Street Name = "Church", Area = "Arlington" />
</Address>
</Person>

What I am interested in setting are the attributes
<Street Name = "Church", Area = "Arlington" />

I tried using System.XML.Serialization.XMLAttribute but it sets the
attributes as attributes of Person.

TIA
Steven.
Nov 15 '05 #1
1 2442
Steven,

In this case, I create a Street object which will expose the Name and
Area properties. Then, on the Street object, apply the XmlAttribute to the
Name and Area properties. Once that is done, have the Street property
expose an instance of the Street class you created.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Steven Quail" <sq******@yahoo.com> wrote in message
news:3a**************************@posting.google.c om...
Hi to all,

I have just started looking at XML.Serialization classes and would
like to know how I set an attribute for an XML element.

For example, I want my XML doc to look like the following:

<Person>
<Name>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
</Name>
<Address>
<Number>127</Number>
<Street Name = "Church", Area = "Arlington" />
</Address>
</Person>

What I am interested in setting are the attributes
<Street Name = "Church", Area = "Arlington" />

I tried using System.XML.Serialization.XMLAttribute but it sets the
attributes as attributes of Person.

TIA
Steven.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: relaxedrob | last post by:
Howdy All! I am really stuck with this one - I want to completely create a table within JavaScript and insert it into the document, with onMouseOut and onMouseOver handlers in the table rows. ...
4
by: G. Richard Bellamy | last post by:
I'm trying to unset the Encrypted attribute on all the files in a path. The attribute is not getting set. What am I doing wrong? Perhaps there's another newsgroup I can send this to? Here's...
3
by: AndyG | last post by:
I'm trying to mess about with a table using javascript. I'm deleting the current row then adding a new row and adding a couple of columns. I then want to add either a style attribute and add a...
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
3
by: Janaka | last post by:
I've seen and used some samples where you can set the onclick attrubute to a Button control to get it to do some javascript a la : btnUse.Attributes = "DoSomeJS()"; However when i try and get...
1
by: Rob Meade | last post by:
Hi all, I have a loop in my code which builds the controls on the page. I at one stage need to add some hidden input controls dynamically, I have achieved this, and I have set their...
1
by: Mark Kamoski | last post by:
Hi-- Is there any significant difference between the code samples below? If so, what is it? And, which is preferred? Also, is there ANY need for setting to Nothing ever in a case like...
3
by: sagar | last post by:
Hello everyone, I am developing a AJAX based IM application. I use javascript to dynamically generated small windows using nested <div> within the web-page. I use the following ways to set...
2
by: Sam | last post by:
Hi all I'm looking for a way to detect the background color of my internal webpage through a stylesheet. And so far, the only solution I find is to open the styles.css file and parse the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
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...
0
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...
0
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...
1
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)...
1
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.