![]() |
nattsurfaren
I think it would be cool to learnhow to use xml feeding withphp. Reason for this thread is that I want your help and suggestions on how to do things even simpler and cleaner or if I'm doing this totally wrong.Goal: Create a simpel xml feed Objectives: Script must use DOM tree to handle xml to simplify coding and resuseability (I think it will :crack ![]() Script must work on shared hosting Tactics: I will use a class called PhpXPath for DOM handling. This doesnt need DOM package to work. I think I had a problem with this before on resellerzoom.You can find out more about this class here: http:// pear.php.net/package/XML_XPathhttp://sourceforge .net/projects/phpxpathI have no clue if this will work or if I need some extra things to make this work. If I make this work I will post the source code here. perkiset
Listen to you, all goals objectives and tactics and such...
Right on man ![]() Post away man, excellent plan. vsloathe
Whoa hey, don't bite down hard with Perk's dong in there!
perkiset
DangerMouse
Are you planning on using
PHP4 or 5? If the latter then the DOM functionality you need is already built in.DM nattsurfaren
![]() Trying to improve myself so I follow perks suggestion on syndk8. I must practise goals, tactics, objectives and strategy. Just to get a feeling for it. Any suggestion to improve this is most appreciated. I have some small sample code here if you're trying the same as me. Not finished yet. require_once("XPath.class. php");$xPath = new XPath("test.xml"); $nodeCollection = $xPath->match("//fruit"); $xPath->insertChild("/sentence[1]/fruit[1]","<test></test>"); $export = $xPath->exportAsXml(); print_r($export); //This must be used in view source to see the xml. This is the xml: <?xml version="1.0"?> <sentence> Today in the market, I spy <vegetable color='green'>cabbages</vegetable>, <fruit color='red'> apples</fruit>,<fruit color='green'> pears</fruit>,<vegetable color='purple'>aubergines</vegetable>, and <fruit color='orange'>oranges</fruit> </sentence> Happy coding. Ohh I forget. This is for you perk ![]() nattsurfaren
quote author=DangerMouse link=topic=859.msg6007#msg6007 date=1207003048 Are you planning on using PHP4 or 5? If the latter then the DOM functionality you need is already built in.DM PHP4Script must work on shared hosting ![]() Well I should change it to Script must work on most shared hosting perkiset
Writing your own XML parser is not trivial. I will post my class so that you can use that in your research. My functional methodology is different than the DOM, but I think the names of the functions will be self explanatory.
Note that the class is bidirectional ie., you can parse/walk existing XML or create new records on the fly really easily. You'll see it in the Show All Unread in just a bit. /p <edit>A benefit of this class is that it is all PHP4 and requires no additional libs at all, it will work on the cheapest hosts around.</edit>nattsurfaren
Very nice, thanks. I will have a go of it.
nattsurfaren
I have successfully added an rss feed to squidoo.
Here is the code I used to produce the feed. <?
php/* TODO: Add code here */ require_once("xmlhandler. php");$xml = new xmlHandler(); $xml->importXML("<?xml version="1.0" ?> <rss version="2.0"></rss>"); $xml->addChild("channel","",true); $xml->addChild("title","My secret feed"); $xml->addChild("description","This is my feed for all pretty women in the world"); $xml->addChild("item","",true); $xml->addChild("title","Nattsurfaren nude in the shower"); $xml->addChild("description","Yes you can see me nude on webcam live. 30 min = $100, 1hr=$200, 2hr=$1000. Pay with paypal, visa, mastercard",false); $xml->addChild("link","http://nudecam.com/natt.htm");/*/**/ $xml->moveToRoot(); $export=$xml->outputAllXML(true); print $export; ?> perkiset
Nice natt, nice to see it working for you.
But not necessarily nice to see <>so much> of you
|
Thread Categories
| Best of The Cache Home | ||
| Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads




