SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool XML/XSLT question

    I been reading up on both. I understand xml and xslt but the question is this. If you needed to load dynamic information would you do that in the xslt file or the xml file? For instance you want to create a news article to use on another site. A news feed. You want to grab the headlines from your db and display it on another site. So would you grab the db info and insert it into a xml file and use xslt to format it? If so anyone have a tutorial on how to dynamically add information into a xml file from a db? Im guessing xml would hold this since the tutorials I been reading state xml is like a portal db or a plain text file holding information. Where xslt is just formatting the xml file.

    Please go easy, im a newb when it comes to this.

    Silly

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For this I have the data from the database pulled based on a query, then put the data to an HTML TABLE.

    For someone else on another site to access this TABLE, they simply place a Javascript link in their HTML somewhere.

    The thing to understand with Javascript is that the browser will still parse it as javascript even though the extension is .php.

    There are various ways of doing a news feed, this is mine. Though there is an article over at xml.com on doing this using only XSL-T - worth a look.

    This is what I'll be using once I've found the time to actually read the article and not merely skim over it. LoL.

    Have a look at www.devarticles.com as they have a few things on using php/mysql/xml/rss for news feeds.

  3. #3
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I remember - the HTML TABLE is created using Javascript btw - with the data read from the database by PHP. 8)

  4. #4
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I actually have done the javascript thing you were talking about. But for the sake of learning and maybe a newsfeed was a bad example, but if you needed to load information dynamically and you are using xml/xslt, would you load the dynamic info into the xml file? If so is there a tutorial on how to do this?

    Silly

    Thanks for the reply!

  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, got you...

    What I do is to include specific tags (well formed so not to throw up Sablotron) which I first parse using PHP.

    Once I come across a specific tag, I replace this tag with stuff generated by PHP. i.e. database, then feed this back into an XML well formed string.

    The content generated by PHP has be reside within tags, which the XSL-T stylesheet will transform to HTML, XML, ... whatever for you.

    About 4-6 weeks ago, I posted by classes and example under the forum 'advanced php' in a thread relating to n tier arch. and the debate about the presentation layer and logic/business layer.

    The early stuff I did is there in a thread, so it will be worth your while taking the time to look back those 6 weeks to see if you can find the thread.

    As to the stuff I'm doing at the moment, I cannot post the scripts, classes, etc. I don't want to either. LoL

    But the early stuff I did is there - so have a look for it, or maybe someone can remember the link/has a bookmark ?

  6. #6
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  7. #7
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So are you saying you would create the xml file in php by making the tags and then "echoing" out the dynamic information between the tags where needed? Then from there just run whatever to get the data?

    If thats the case where would the xml file go if you wanted someone to do their news feed on another domain? How would you include it so it would display on someone elses website?

    Silly

  8. #8
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, that's the post.

    Nope; the xml file is your bog standard file with well formed xml tags;

    PHP Code:
    <table>
    <
    row>
    <
    cell width='100%'><import /></cell>
    </
    row>
    </
    table
    The tag above, 'import' is what I parse for in a PHP function and replace this tag with data pulled from the database for example.

    As to your main point, if you want someone else to view your news feed on their site from your site you need to provide a link that the user using your news feed can use.

    This link (I use Javascript) will then put in a users site the content generated by your link. What your link generates is up to you.

    How you generate the content is what your question is really asking ? I use basic HTML TABLEs at the moment; not got around to changing things to use XML/XSL at the moment.

    What I'd do is take your data from the database and place this data into RSS compliant XML tags, and then find an RSS parser to parse your newly created RSS tags to (x)HTML.

    This is what your user will eventually have on their web page.

    The benifit of using RSS is then you can submit your news to aggregators such as moreover.com for example, though personally I don't use RSS just now.

    As for my scripts, I did'nt design them to use RSS - something for later inclusion maybe ?

    Hope this helps ?


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
  •