Click here to Skip to main content
16,017,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts..

I have one XML file.
<Rating>
            <RatingInterval>1</RatingInterval>
            <RatingCount>18</RatingCount>
          </Rating>
          <Rating>
            <RatingInterval>2</RatingInterval>
            <RatingCount>4</RatingCount>
          </Rating>
          <Rating>
            <RatingInterval>3</RatingInterval>
            <RatingCount>20</RatingCount>
          </Rating>
          <Rating>
            <RatingInterval>4</RatingInterval>
            <RatingCount>5</RatingCount>
          </Rating>
          <Rating>
            <RatingInterval>5</RatingInterval>
            <RatingCount>7</RatingCount>
          </Rating>
    </Rating>


My requirement is have to calculate how many rating count for every rating interval.

Rating Interval 1 = 18

Rating Interval 2 = 4

Rating Interval 3 = 20

Rating Interval 4 = 5

Rating Interval 5 = 7

There is lots of <rating> tags. I have to extract all the data. Please help me, How to extract the values.
Posted
Comments
Jim Meadors 14-Mar-14 1:33am    
It would be helpful for you to say what form you want the data extracted into, as you already have all the data in your original xml file.
Vijaydhas 14-Mar-14 1:46am    
Rating Interval 1 = 18

Rating Interval 2 = 4

Rating Interval 3 = 20

Rating Interval 4 = 5

Rating Interval 5 = 7

I have to extract like this..
Jim Meadors 14-Mar-14 2:16am    
See code below. It will run in a console application with your xml.

1 solution

Dim ratings As XElement = XElement.Parse("YOUR XML HERE")
For Each ele In ratings.Elements
Console.WriteLine("Rating Interval " & ele.<ratinginterval>.Value & " = " & ele.<ratingcount>.Value)

Next
Console.ReadLine()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900