Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XML attribute name/value pairs

2 views
Skip to first unread message

Peter

unread,
Apr 9, 2010, 10:07:02 AM4/9/10
to
I have an XML file where an element has 2 attributes, type and value. The
type attribute contains the field name, the value attribute contains the
value of the field. How do I make that assignment happen?

Here's what it looks like:
<VehicleAttributes>
<VehicleAttribute type="VehicleType" value="Truck"/>
<VehicleAttribute type="Year" value="2005"/>
<VehicleAttribute type="BodyStyle" value="Cab Chassis" />
<VehicleAttribute type="Make" value="Ford" />
<VehicleAttribute type="Model" value="F-450" />
<VehicleAttribute type="Series" value="Super Duty" />
</VehicleAttributes>


Here's the same thing in a format that my app (SQL Server SSIS) understands.
I had to edit this by hand to support my question:
<VehicleAttributes>
<VehicleAttribute VehicleType="Truck"/>
<VehicleAttributeYear="2005"/>
<VehicleAttribute BodyStyle="Cab Chassis"/>
<VehicleAttribute Make="Ford"/>
<VehicleAttributeModel="F-450"/>
<VehicleAttribute Series="Super Duty"/>
</VehicleAttributes>


The outputs from the VehicleAttribuute element are type and value. I want
them to be VehicleType, Year, BodyStyle, Make, Model and Series. How to do?

Luuk

unread,
Apr 9, 2010, 1:28:05 PM4/9/10
to
Op 9-4-2010 16:07, Peter schreef:

> <VehicleAttributes>
> <VehicleAttribute VehicleType="Truck"/>
> <VehicleAttributeYear="2005"/>
> <VehicleAttribute BodyStyle="Cab Chassis"/>
> <VehicleAttribute Make="Ford"/>
> <VehicleAttributeModel="F-450"/>
> <VehicleAttribute Series="Super Duty"/>
> </VehicleAttributes>


would this not be easier/better/....?:

<VehicleAttributes>
<VehicleAttribute VehicleType="Truck" Year="2005" BodyStyle="Cab
Chassis" Make="Ford" Model="F-450"/ Series="Super Duty">
</VehicleAttributes>

--
Luuk

0 new messages