Jump to content

fogofogo

Members
  • Posts

    7
  • Joined

  • Last visited

fogofogo's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hello folks.I have a question about using php to select a file according to date. I am working on a project that uses xml to display horoscopes on a website. The xml feeds are ftp'd onto our server and have a different file name depending on the date. Unfortunetly this is the only way the xml is available.The filenaming is:Feed_name_YYYYMMDDHHMMSS_$storyid.xmlFor example:TMG_Horoscopes_Daily_Virgo_media_20060216100017_985313.xmlI'll be using php to do this, and as I'm fairly new to it, I'm not sure where to go from here. Does anyone have any advice, scripts or tutorials that might be able to help me?Thanks guys,John
  2. Hello folks, I'm not sure if this is in the write place - so I apologise if it is not.I've been asked to integrates some xml into a php page. The xml file is dropped into a folder on our webserver on a daily basis and is given a new name. ( for example TMG_Horoscopes_Daily_Virgo_media_20060213100013985277_.xml area in bold is the part that changes). My problem is, I'm not sure how to go check for the most recently added file and make sure its the correct on (ie virgo). Anyone have an similar problems and could offer some advice, or know of any script that could help?Thanks!J
  3. nice one man - all fixed!
  4. Hello All,I have a page that passes a session variable to another page which is then used in an if/else statement. For some reason itsa giving me error messages, and I'm not sure whats up with it.Heres the page that creates the variable <?phpsession_start(); // start session$_SESSION['name'] = 'sport';?> and heres the page with the if else statment : and finally - here are the error messages that I am getting : As you've guessed, I'm pretty new to this so I have probably missed something basic - any ideas?CheersFogo
  5. problem solved If anyone is interested, here is the solution: Dim XMLDomDim ItemIDDim DbConnDim SQLStringDim ANArticleNodeDim ANArticleNode2Dim CollectionOfArticleNodesDim CollectionOfArticleNodes2Dim cstSet XMLDom = CreateObject("MSXML2.DomDocument.4.0")XMLDom.async = FalseXMLDom.setProperty "ServerHTTPRequest", TrueSet DbConn = Createobject("adodb.connection")DbConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=test1.mdb"'-- Load the XML data from your live URLXMLDom.Load("http://feeds.directnews.org.uk/?ad96035d-f9fe-4a3f-a5b2-ad546b2ed850") '-- Create a reference to a collection of all Article Tags within the downloaded XML DocumentSet CollectionOfArticleNodes = XMLDom.SelectNodes("InfoStreamResults/Article")'-- Iterate the collection of Article Tags For Each ANArticleNode in CollectionOfArticleNodes '-- Now create a reference to the category tag Set CollectionOfArticleNodes2 = ANArticleNode.SelectNodes("Categories/Category") '-- And iterate through the nodes to test for a match For Each ANArticleNode2 in CollectionOfArticleNodes2 ItemID = ANArticleNode2.SelectSingleNode("@ID").text if ItemID = "430009735" then '-- Retrieve the value of the heading node from the current article Heading = ANArticleNode.SelectSingleNode("Heading").text '-- Insert the item into the local database SQLString = "INSERT INTO test (Heading) " _ & "VALUES('" & EncodeIt(Heading) & "');" DbConn.Execute(SQLString) end if Next '-- check the next category IDNext '-- move to the next article'-- Handles quotations in textFunction EncodeIt(TextString) TextString = Replace(CStr(TextString), "''", "'") TextString = Replace(TextString, "'", "''") EncodeIt = TextStringEnd Function%>
  6. Hello All,I have a question regarding searching and selecting certain elements in an XML document using asp. The xml script basically consist of news headings, contents, date, and category elements that tell what the news is related to and where it should be displayed and stored. For example Finance catagory stories will be stored in a different database to the business one. <Article Created="16:01:59" ID="15105602"> <Heading>Equitable drops claim against former directors</Heading> <Date>02/12/2005</Date> <Contents> <news story goes in here> </Contents> <Categories> <Category ID="430009725">Finance</Category> <Category ID="430009734">Economy</Category> <Category ID="430009735">Business</Category> <Category ID="438000159">Insurance</Category> </Categories></Article> So basically I need a script that can check the XML for certain stories and store them in a database. I already have the script (see below) that takes ALL the news stories from the XML file and puts them in a database. So how can I get the script to check if a story is, say a Finance story and continue to store it in a database? Would I use an if else statment? if so, where should I put it? Dim XMLDomDim ItemIDDim DbConnDim SQLStringDim ANArticleNodeDim CollectionOfArticleNodesDim cstSet XMLDom = CreateObject("MSXML2.DomDocument.4.0")XMLDom.async = FalseXMLDom.setProperty "ServerHTTPRequest", TrueSet DbConn = Createobject("adodb.connection")'DbConn.open "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=pokernewsxml; OPTION=3"DbConn.open "Driver={MySQL ODBC 3.51 Driver};" & _ "Server=82.195.128.88;" & _ "Database=johnfog_xml;" & _ "Uid=johnfog_xml;" & _ "Pwd=wordword;"'-- Load the XML data from your live URLXMLDom.Load("http://feeds.directnews.org.uk/?ad96035d-f9fe-4a3f-a5b2-ad546b2ed850") '-- Create a reference to a collection of all Article Tags within the downloaded XML DocumentSet CollectionOfArticleNodes = XMLDom.SelectNodes("InfoStreamResults/Article")'-- Iterate the collection of Article Tags For Each ANArticleNode in CollectionOfArticleNodes ItemID = ANArticleNode.SelectSingleNode("@ID").text Heading = ANArticleNode.SelectSingleNode("Heading").text Contents = ANArticleNode.SelectSingleNode("Contents").text sDate = ANArticleNode.SelectSingleNode("Date").text '-- Delete the item from the local database if it exists SQLString = "DELETE FROM DeHavillandNews WHERE trim(ItemID)='" & trim(ItemID) & "';" DbConn.Execute(SQLString) '-- Insert the item into the local database SQLString = "INSERT INTO DeHavillandNews (ItemID,Heading,Contents,strDate) " _ & "VALUES('" & ItemID & "','" & EncodeIt(Heading) & "','" & EncodeIt(Contents) & "', '" & sDate & "');" DbConn.Execute(SQLString) Next'-- Handles quotations in textFunction EncodeIt(TextString) TextString = Replace(CStr(TextString), "''", "'") TextString = Replace(TextString, "'", "''") EncodeIt = TextStringEnd Function Any help would be greatly appreciated as I am seriously stuck with this one.Thanks folksJ(changed display to code box to save room - skemcin)
  7. Hello folks,I have an xml feed which is formated in an .xsl document and then it is displayed with a asp page.I'm trying to display the top 10 results from the feed but I'm unsure how to do this. I tried putting a loop in the asp file but it didn't work for me. So I'm guessing the loop was to be placed in the xsl document? Anyone know what the code would be or where I find further information about it? here is my .xsl code : <?xml version="1.0" encoding="windows-1252" standalone="yes" ?><xsl:stylesheet xmlns sl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="html" indent="yes" omit-xml-declaration="no"/> <xsl:template match="InfoStreamResults"><xsl:apply-templates select="Article"/></xsl:template><xsl:template match="Article"><A><xsl:attribute name="HREF">ItemPage.asp?ItemID=<xsl:value-of select="@ID"/></xsl:attribute><B><xsl:value-of select="Heading"/></B></A><br/> </xsl:template></xsl:stylesheet> Apologies for the basic question, I'm fairly new to XML.ThanksFogo
×
×
  • Create New...