Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Read XML file into GridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dba123 - 28 Aug 2006 02:15 GMT
I need help in coding the following or if you can just point me in the right
direction:

1)  Reading  the follwoing XML document
2) Hook up a GridView to the data received from the XML document.  The Grid  
should read lke this:

Title
Description
Title
Descripti0n

...and so on

Here's the XML document format (I replaced  our stuff with fake text for
privacy p urposes...so ignore the weirdness of the text values):

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
    <channel>
         <title>Ken Smith<title>
         <link>http://www.sss.com</link>
         <language>en-us</language>
         <itunes:subtitle>Rroundtable for a lively discussion of the week's
news.</itunes:subtitle>
         <itunes:author>sss.com</itunes:author>
         <description> listeners turn to the Editors Roundtable for...
</description>
         <image>
              <url>http://localhost/images/header/sss_logo.jpg</url>
              <title>Roundtable</title>
              <link>http://www.sss.com</link>
         </image>
         <itunes:owner>
              <itunes:name>sss.com</itunes:name>
              <itunes:email>info@csss.com</itunes:email>
         </itunes:owner>
         <itunes:image href="http://www.sss.com/images/header/sss_logo.jpg"
/>
         <itunes:category text="sdfdfsd" />
         <item>
              <title>Recent trip to Chiapas</title>
              <link>http://localhost/interact/podcasts/mp3s</link>
              <description>Retrip to Chiapas, Mexico.  This award-winning
author, and Mexican...</description>
              <enclosure
url="http://localhost/interact/podcasts/mp3s/ss_Final.mp3" type="audio/mp3" />
              <pubDate>Wed, 16 Aug 2006 13:00:00 GMT</pubDate>
              <itunes:author>sss</itunes:author>
              <itunes:duration>12:33</itunes:duration>
         </item>
         <item>
              <title>Adam Smith</title>
              <link>http://localhost/interact/podcasts/mp3s</link>
              <description>Ken from ssscom discusses....</description>
              <enclosure
url="http://localhost/interact/podcasts/mp3s/Seger2FINAL.mp3"
type="audio/mp3" />
              <pubDate>Wed, 09 Aug 2006 13:00:00 GMT</pubDate>
              <itunes:author>Ken Smoth</itunes:author>
              <itunes:duration>8:27</itunes:duration>
         </item>
Signature

dba123

dba123 - 28 Aug 2006 02:19 GMT
This is the code we had before when we were reading it into a texbox.  I want
to  instead read this into a GridView

           try
            {
                StringBuilder sb = new StringBuilder();
                XmlDocument doc = new XmlDocument();
                doc.Load(Server.MapPath("/interact/podcasts/rss/podcast.xml"));
           
                XmlNodeList items = doc.SelectNodes("//item");  
           
                for (int i=0; i<items.Count ; i++)
                {
               
                    sb.Append( string.Format( "<tr valign='top'><td><a href={0}><img
src='/images/interact/icon_podcast.gif' border=0></a></td><td><a
href={0}>{1}</a></td></tr><tr><td></td><td>{2}</td></tr><tr><td><img
src='/images/spacer.gif' width=1 height=3 border=0 alt=''></td></tr>"
                        , items[i].SelectSingleNode("enclosure").Attributes["url"].InnerText
                        , items[i].SelectSingleNode("title").InnerText
                        , items[i].SelectSingleNode("description").InnerText  )    ) ;//"<br>"
+ items[i].SelectSingleNode("title").InnerText +  "<br>" ) ;
                }  

Now I want to read teh sb.ToString to GridView...

Signature

dba123

> I need help in coding the following or if you can just point me in the right
> direction:
[quoted text clipped - 58 lines]
>                <itunes:duration>8:27</itunes:duration>
>           </item>
Prem Kumar - 28 Aug 2006 10:43 GMT
Hi

Not sure about this approach, but a try ..

Why don't u read the xml in a dataset, using the ReadXML method and once you
have the info in dataset, you could bind the necessary columns in the
Gridview.

Prem

> This is the code we had before when we were reading it into a texbox.  I want
> to  instead read this into a GridView
[quoted text clipped - 84 lines]
> >                <itunes:duration>8:27</itunes:duration>
> >           </item>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.