Do not use on any
shared computer
July 27, 2008 01:35am pdt
null
[x]
Attachment Details

Importing XML into dataset using XSL file

Tags: ASP .net C# XML XSL, All Browsers
Hi Experts
I have sucessfully managed to import an xml file into a dataset using an XSL file using the following code
        dsClicks.ReadXmlSchema(Server.MapPath("data/import1.xsl"));
        dsClicks.ReadXml(Server.MapPath("data/import1.xml"));
        DataTable dtClicks = dsClicks.Tables["Row"];
I am now trying to import another xml file that has a slightly different structure to the first one. I am able to get the date attribute in but I can't seem to get any of the analytics attributes into the data table as well. In the code snippet I have included the xml and the xsl structure of the second file i wish to import.

Regards
Steve
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
import2.xsl
~~~~~~~~~~~
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="row">
     <xs:complexType>
         <xs:attribute name="date"/>
  	   <xs:attribute name="numImpr"/>
	   <xs:attribute name="numClick"/>
	   <xs:attribute name="cost"/>
     </xs:complexType>
 </xs:element>
 </xs:schema>
 
import2.xml
~~~~~~~~~~~
<?xml version="1.0" encoding="UTF-8"?>
<report name="YSM Performance By Date" masterAccountID="123456" masterAccountName="Account" dateStart="2007-01-01+0000" dateEnd="2007-12-31+0000" booksClosedTimestamp="2008-01-17T09:00:00.000+0000" booksClosed="true" createDate="2008-01-17T09:46:41.360+0000" sortColumn="date" sortOrder="asc">
<row date="2007-06-28+0100"><analytics numImpr="5" ctr="0.0" numClick="0" cost="0.0"/></row>
<row date="2007-06-29+0100"><analytics numImpr="15" ctr="0.06666666666666667" numClick="1" cpc="0.05" cost="0.05"/></row>
<row date="2007-06-30+0100"><analytics numImpr="21" ctr="0.23809523809523808" numClick="5" cpc="0.11" cost="0.55"/></row>
</report>
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Web Development
Question Asked By: fusioninternet
Solution Provided By: fusioninternet
Participating Experts: 1
Solution Grade: A
Views: 62
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by slamhound

Rank: Master

Expert Comment by slamhound:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by fusioninternet
Author Comment by fusioninternet:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by fusioninternet
Accepted Solution by fusioninternet:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628