RSS is now very popular and once popular on the Internet. Indeed, it has brought us great changes and convenience! There are also many RSS versions, including rss.1.0.rss2.0 and Atom!
I encountered a lot of problems when parsing, because I have not studied XML and related parsing work, so I have encountered a lot of problems and can successfully parse rss2.0 at present.
Some resolutions on the top (for now, I don't know what it is)
1 Private Void Getrsshead (xmldocument DOC)
2 {
3 // Xmldocument Doc = new xmldocument ();
4 // Doc. loadxml (this. rssxmlstr );
5 Xmlelement ELEM = (Xmlelement) Doc. documentelement. firstchild;
6 This . Headtitle = ELEM. selectsinglenode ( " Title " ). Innertext;
7 This . Headurl = ELEM. selectsinglenode ( " Link " ). Innertext;
8 This . Headdescription = ELEM. selectsinglenode ( " Description " ). Innertext;
9
10 }
Content parsing:
1 Private Void Parseitems ()
2 {
3 Xmldocument Doc = New Xmldocument ();
4 Doc. loadxml ( This . Rssxmlstr );
5 Xmlnodelist nodelist;
6 Xmlelement Root = Doc. documentelement;
7 Nodelist = Root. getelementsbytagname ( " Item " );
8 For ( Int N = 0 ; N < Nodelist. Count; n ++ )
9 {
10 Listtitle. Add (nodelist [N]. selectsinglenode ( " Title " ). Innertext );
11 Listlink. Add (nodelist [N]. selectsinglenode ( " Link " ). Innertext );
12 Listdescription. Add (nodelist [N]. selectsinglenode ( " Description " ). Innertext );
13 }
14 }
However, for rss1.0, I can only handle this currently: 1 // Header
2 Nodelist = Root. getelementsbytagname ( " Channel " );
3 This . Headtitle = Nodelist [ 0 ]. Childnodes [ 0 ]. Innertext;
4 This . Headurl = Nodelist [ 0 ]. Childnodes [ 1 ]. Innertext;
5 This . Headdescription = Nodelist [ 0 ]. Childnodes [ 2 ]. Innertext;
6
You cannot use selectsinglenode to retrieve elements. In this way, RSS cannot change the order, and the atom format cannot be processed well!