EDN Admin
Well-known member
I have an xml file that looks like this
<div style="background-color:white; color:black
<pre><span style="color:blue <?<span style="color:#a31515 xml <span style="color:red version<span style="color:blue =<span style="color:black "<span style="color:blue 1.0<span style="color:black " <span style="color:red encoding<span style="color:blue =<span style="color:black "<span style="color:blue utf-8<span style="color:black "<span style="color:blue ?>
<span style="color:blue <<span style="color:#a31515 dataset <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue http://developer.cognos.com/schemas/xmldata/1/<span style="color:black " <span style="color:red xmlns:xs<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2001/XMLSchema-instance<span style="color:black "<span style="color:blue >
<span style="color:green <!--
<dataset
xmlns="http://developer.cognos.com/schemas/xmldata/1/"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://developer.cognos.com/schemas/xmldata/1/ xmldata.xsd"
>
-->
<span style="color:blue <<span style="color:#a31515 metadata<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Employee Name (Last Suffix, First MI)<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 2414<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Preferred First Name<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 202<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Employee Number<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 20<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Org Level 1<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 52<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Org Level 2<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 52<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Org Level 3<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 52<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Supervisor Name (Last Suffix, First MI)<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 2414<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Supervisor Employee Number<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 20<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Employment Status Code<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 4<span style="color:black "<span style="color:blue />
<span style="color:blue </<span style="color:#a31515 metadata<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 data<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 row<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Abercrombie, Brett C. <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Brett<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >001911 <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >CRC<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Service<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Earth Moving<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Franklin, James E. <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >000450 <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >A<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 row<span style="color:blue >
[/code]
<pre>Im wanting to populate a datatable with the "<values>" based on the metadata tags. How do I go about accomplishing this in VS 2010 C#. Ive never really done anything with xml files so Im kind of lost on where to start.[/code]
Ive tried the following:
<div style="background-color:white; color:black
<pre> <span style="color:blue string file = <span style="color:#a31515 @"C:tempfile.xml";
DataSet ds = <span style="color:blue new DataSet();
ds.ReadXml(file, XmlReadMode.InferSchema);
<span style="color:blue return ds.Tables[4];
[/code]
but its not giving me what I want. Im wanting the DataTable to have the column names of the metdata items with the corresponding values in each row.
<br/>
View the full article
<div style="background-color:white; color:black
<pre><span style="color:blue <?<span style="color:#a31515 xml <span style="color:red version<span style="color:blue =<span style="color:black "<span style="color:blue 1.0<span style="color:black " <span style="color:red encoding<span style="color:blue =<span style="color:black "<span style="color:blue utf-8<span style="color:black "<span style="color:blue ?>
<span style="color:blue <<span style="color:#a31515 dataset <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue http://developer.cognos.com/schemas/xmldata/1/<span style="color:black " <span style="color:red xmlns:xs<span style="color:blue =<span style="color:black "<span style="color:blue http://www.w3.org/2001/XMLSchema-instance<span style="color:black "<span style="color:blue >
<span style="color:green <!--
<dataset
xmlns="http://developer.cognos.com/schemas/xmldata/1/"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://developer.cognos.com/schemas/xmldata/1/ xmldata.xsd"
>
-->
<span style="color:blue <<span style="color:#a31515 metadata<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Employee Name (Last Suffix, First MI)<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 2414<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Preferred First Name<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 202<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Employee Number<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 20<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Org Level 1<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 52<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Org Level 2<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 52<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Org Level 3<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 52<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Supervisor Name (Last Suffix, First MI)<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 2414<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Supervisor Employee Number<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 20<span style="color:black "<span style="color:blue />
<span style="color:blue <<span style="color:#a31515 item <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue Employment Status Code<span style="color:black " <span style="color:red type<span style="color:blue =<span style="color:black "<span style="color:blue xs:string<span style="color:black " <span style="color:red length<span style="color:blue =<span style="color:black "<span style="color:blue 4<span style="color:black "<span style="color:blue />
<span style="color:blue </<span style="color:#a31515 metadata<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 data<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 row<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Abercrombie, Brett C. <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Brett<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >001911 <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >CRC<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Service<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Earth Moving<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >Franklin, James E. <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >000450 <span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 value<span style="color:blue >A<span style="color:blue </<span style="color:#a31515 value<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 row<span style="color:blue >
[/code]
<pre>Im wanting to populate a datatable with the "<values>" based on the metadata tags. How do I go about accomplishing this in VS 2010 C#. Ive never really done anything with xml files so Im kind of lost on where to start.[/code]
Ive tried the following:
<div style="background-color:white; color:black
<pre> <span style="color:blue string file = <span style="color:#a31515 @"C:tempfile.xml";
DataSet ds = <span style="color:blue new DataSet();
ds.ReadXml(file, XmlReadMode.InferSchema);
<span style="color:blue return ds.Tables[4];
[/code]
but its not giving me what I want. Im wanting the DataTable to have the column names of the metdata items with the corresponding values in each row.
<br/>
View the full article