SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parsing the "description" element of rss/xml

    Hello, I have php code which takes an rss feed and outputs it on a page of my website. For each item it shows the link, title and description.

    My problem is the description element contains a lot of information (4 links and other stuff) and I want to extract one of the links out of this information, so that on my webpage I am shown the link, title and the link I want out of the description, for every item. How would I achieve this? If no-one knows can anyone point me to books which might know.

    To rephrase my goal: <description>bla bla bla .... [link] ...bla bla bla<description/> I want to extract the link out of the description node/element.

    Any ideas would be gratefully received.

    Thank you

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2009
    Location
    Bavaria, Germany
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like simple parsing and you can use php stuff like XMLReader or regex for that.

  3. #3
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much for the response.

    To be clear, I already have the code which displays the data inside the "description" node. I want to be able to automatically extract the right link from within the text inside the description node and display that (there are no families within the description node just lots of text and some links).

    Xmlreader will achieve this? I have been looking at the documentation but don't see a way to do it.

  4. #4
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are not clear..

    description has lot of information, 4 links. so, which one do you wanna extract from those 4 links?

    1, 2, 3 or 4, do you know that?

    and also which language are you using? ASP or PHP?

    I don't know PHP, but in ASP you can do it like this;

    after you parsing your XML, you work with description. you can use regular expression for extracting those 4 links and while extracting, you can do what ever you want. but if you know which one do you wanna extract, then while extracting you can do some special thing with the mach.

    hope helpful or gives you idea.

  5. #5
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey thanks for the reply but don't worry that was two weeks ago. I have come a LONG way since then, I can parse documents in my sleep now


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •