473,461 Members | 1,109 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Generate attribute instead of element node

Hi,

how do I generate attribut instead of element name? For example:

I want:
<car
name="Ford"
/>

instead of
<car
<name>Ford</name>
</car>

I have a class such as:
public __gc class Car {
System::String* name;
};

I think it can be done by adding [XmlAttribute("name")] right above
System::String* name; but I can't compile it because of error: error C2337:
'XmlAttribute' : attribute not found; it is neither a built-in nor a custom
attribute that is accessible in the current namespace

How do I do this? I am using managed C++.
Thank you!

--
Daniel
Nov 12 '05 #1
3 2452
Daniel Lidström wrote:

I think it can be done by adding [XmlAttribute("name")] right above
System::String* name; but I can't compile it because of error: error C2337:
'XmlAttribute' : attribute not found; it is neither a built-in nor a custom
attribute that is accessible in the current namespace


It's System.Xml.Serialization.XmlAttributeAttribute.
I believe in C++ you have to use full name:
[XmlAttributeAttribute("name")]

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
You should either use the full class name or import the namespace:

[System.Xml.Serialization.XmlAttribute("name")]

--
Daniel Cazzulino [MVP XML]
Clarius Consulting SA
http://weblogs.asp.net/cazzu
http://aspnet2.com

"Daniel Lidström" <so*****@microsoft.com> wrote in message
news:w6******************************@40tude.net.. .
Hi,

how do I generate attribut instead of element name? For example:

I want:
<car
name="Ford"
/>

instead of
<car
<name>Ford</name>
</car>

I have a class such as:
public __gc class Car {
System::String* name;
};

I think it can be done by adding [XmlAttribute("name")] right above
System::String* name; but I can't compile it because of error: error C2337: 'XmlAttribute' : attribute not found; it is neither a built-in nor a custom attribute that is accessible in the current namespace

How do I do this? I am using managed C++.
Thank you!

--
Daniel

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.679 / Virus Database: 441 - Release Date: 08/05/2004
Nov 12 '05 #3
On Mon, 17 May 2004 15:29:30 +0200, Oleg Tkachenko [MVP] wrote:
Daniel Lidström wrote:

I think it can be done by adding [XmlAttribute("name")] right above
System::String* name; but I can't compile it because of error: error C2337:
'XmlAttribute' : attribute not found; it is neither a built-in nor a custom
attribute that is accessible in the current namespace


It's System.Xml.Serialization.XmlAttributeAttribute.
I believe in C++ you have to use full name:
[XmlAttributeAttribute("name")]


Thanks Oleg,

this solved my problem.

--
Daniel
Nov 12 '05 #4

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

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
2
by: Anthony LaMark | last post by:
Hi All, I am generating a (X)HTML page in an IE webbrowser control (housed by a .Net WinForm application) from a XML file using XSLT (using Msxml2.DOMDocument.4.0). When the user clicks a...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
8
by: patrizio.trinchini | last post by:
Hi All, I'would like to write an XSL transformation that changes the value of the atribute of a given element according to the value of another atttribute of the same element. For instance,...
3
by: patrizio.trinchini | last post by:
Hi, how can remove sibling elements based on the value of an attribute ? For instance, gven the XML document: <root> <parentElment> <testElement name="A"> <removableElement/>
7
by: Ebenezer | last post by:
Hello! Let's suppose we have an XML with some nested NODE nodes: <root attr="first"> <node id="1" attr="mike"> <node id="2" /> <node id="3" attr="dave" /> </node> <node id="4">
1
by: krunaldsoni | last post by:
Let me give you my problem statement: <positiondata > <touchpad reportedFingers="2" /> <timestamp user="Dev" time="1252088979018" /> <reported2d x="447" y="232" z="31" w="1" finger="0"...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
1
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.