473,396 Members | 1,929 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,396 software developers and data experts.

XMLLiteral - Generate Dynamic Attributes

I need to generate an XElement with an indeterminate number of attributes
whose names and values will have previously have been added to a dictionary(Of
String, String)

-------------------------------------------------------------
Private Attributes As New Dictionary(Of String, String)
Public Overrides Function GenerateXElement() As XElement
Return <DocElement>
<InnerElement <%= From Attribute In Attributes Select
SomethingHereIGuess %/>
</DocElement>
End Function
-------------------------------------------------------------

This is kinda what I want but I have no Idea what the syntax is.

Anyone have an Idea?

--
Rory
Jun 27 '08 #1
2 1048
Rory Becker wrote:
I need to generate an XElement with an indeterminate number of
attributes whose names and values will have previously have been added
to a dictionary(Of String, String)

-------------------------------------------------------------
Private Attributes As New Dictionary(Of String, String)
Public Overrides Function GenerateXElement() As XElement
Return <DocElement>
<InnerElement <%= From Attribute In Attributes
Select SomethingHereIGuess %/>
</DocElement>
End Function
-------------------------------------------------------------

This is kinda what I want but I have no Idea what the syntax is.
The following might show what you are looking for:

Dim col As Dictionary(Of String, String) = New Dictionary(Of
String, String)()
col.Add("att1", "value 1")
col.Add("att2", "value 2")

Dim foo As XElement = <foo <%= From p In col Select New
XAttribute(p.Key, p.Value) %>></foo>
foo.Save(Console.Out)
Result is <foo att1="value 1" att2="value 2"></foo>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
Hello Martin,
The following might show what you are looking for:

Dim col As Dictionary(Of String, String) = New Dictionary(Of
String, String)()
col.Add("att1", "value 1")
col.Add("att2", "value 2")
Dim foo As XElement = <foo <%= From p In col Select New
XAttribute(p.Key, p.Value) %>></foo>
foo.Save(Console.Out)
Result is <foo att1="value 1" att2="value 2"></foo>
Thanks very much Martin. That looks great.

--
Rory
Jun 27 '08 #3

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

Similar topics

4
by: Richard Abraham | last post by:
I have created a new class ServiceTimer based upon the .NET System.Timers.Timer class. This has a new property CollectionIntervalMinutes which I expected to be added to the 'Behavior' section of the...
1
by: A Traveler | last post by:
Hello, i am having this problem. The exact error message is: "Unable to generate code for a value of type 'System.Web.UI.Page'. This error occurred while trying to generate the property value for...
8
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they...
3
by: Dave Rose | last post by:
Hello all. I was wondering if creating classes could be dynamic. I want to know if I can make a class Person, then read in a list of names (say people's names) so then I can have a class instance...
2
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous...
1
gxlrygt
by: gxlrygt | last post by:
this is the dynamic menu of my site. it works clearly but i need a shorter and simpler function. help me pls. thanks http://www.caddy-tasarim.com/m.jpg XML <root> <m t="1"> <m t="1.1"/>...
3
by: =?Utf-8?B?U3ViYQ==?= | last post by:
I am using a asp page to dynamically create a stylesheet my asp page creates the following css element when i call the asp page my typing the url in the browser. My asp page works...
1
by: SunshineInTheRain | last post by:
The following code is dynamic create dropdownmenu which data within pulled from database However, the code work well on IE but not on Firefox. On Firefox, the whole mouseover and mouseout function...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.