Android Question how detect img tag rss

Discussion in 'Android Questions' started by omidaghakhani1368, Feb 24, 2015.

  1. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi.
    The structure of rss is :
    <?xml version="1.0" encoding="UTF-8" ?>
    <rss version="2.0">
    <channel>
    <title>W3Schools Home Page</title>
    <link>http://www.w3schools.com</link>
    <description>Free web building tutorials</description>
    <image>
    <url>http://www.w3schools.com/images/logo.gif</url>
    <title>W3Schools.com</title>
    <link>http://www.w3schools.com</link>
    </image>
    <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3schools.com/rss</link>
    <description>New RSS tutorial on W3Schools</description>
    </item>
    </channel>
    </rss>

    How i detect img tag in rss?
     
  2. sorex

    sorex Expert Licensed User

    quick and dirty...

    Code:
    Log(rss.SubString2(rss.IndexOf("url")+4,rss.IndexOf("</url>")))
     
    KZero likes this.
  3. KZero

    KZero Active Member Licensed User

    using XMLSax Library

    Code:
    Sub Globals
    Dim Parser As SaxParser
    End Sub

    Dim In As InputStream
    In=File.OpenInput(File.DirAssets, "1.xml")
    Parser.Initialize
    Parser.Parse(
    In,"Parser")

    Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
        
    If Name="url" Then
           
    Log(Text.ToString)
        
    End If
    End Sub
     
    omidaghakhani1368 likes this.
  4. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Thank you.I thought i can not use Parser to detect img tag
     
    KZero likes this.
  5. sorex

    sorex Expert Licensed User

    there are several methods to get that data, it just depends on how you want to do it.

    mine: small, library-less and ideal for beginners but quick and dirty
    Kzero's: needs a library and more code
    regex: too tricky for beginner

    if the rss contains 2 or more images you better use Kzero's method as mine would only pick the first one unless your rewrite it a bit.
     
    KZero likes this.
  6. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Thank you I successfull
     
    KZero likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice