nattsurfaren


I think it would be cool to

learn

  how to use xml feeding with

php

 . 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  :crackApplause
Script must work on shared hosting

Tactics:
I will use a class called

Php

 XPath 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_XPath
http://sourceforge

.net

 /projects/

php

 xpath

I 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 Applause

Post away man, excellent plan.

vsloathe

Whoa hey, don't bite down hard with Perk's dong in there!

perkiset

Applause Applause Applause Applause

DangerMouse

Are you planning on using

PHP

  4 or 5? If the latter then the DOM functionality you need is already built in.

DM

nattsurfaren

Applause Applause Applause Applause Applause  Applause  Applause Applause

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'>

apple

 s</fruit>,
<fruit color='green'>

pear

 s</fruit>,
<vegetable color='purple'>aubergines</vegetable>, and
<fruit color='orange'>oranges</fruit>
</sentence>

Happy coding. Ohh I forget. This is for you perk  Applause


nattsurfaren

quote author=DangerMouse link=topic=859.msg6007#msg6007 date=1207003048

Are you planning on using

PHP

  4 or 5? If the latter then the DOM functionality you need is already built in.

DM


PHP

  4
Script must work on shared hosting  Applause
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

PHP

 4 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.  Applause

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  Applause


Perkiset's Place Home   Politics @ Perkiset's