示例#1
0
# example 2 (just to reiterate on the modular example)
#-----------------------------------------------------------
$xmlData = new Silkworm("xml");
//this sets silkworm to default to xml styles
$xmlData->xmlVersion("1.0", array("encoding" => "utf-8"));
//XML version definition
$xmlData->doctype("HTML");
//doctype definition
#same object, different structure
$xmlData["novels"] = $xmlData->writtenMedia($xmlData->horror($xmlData->work("death"), $xmlData->work("pain"), $xmlData->work("suffering")), $xmlData->fantasy($xmlData->work("dragons"), $xmlData->work("magic"), $xmlData->work("fire wildthings")), $xmlData->scienceFiction($xmlData->work("L.A.S.E.R.s"), $xmlData->work("hyper warp"), $xmlData->work("time parameter")));
#same object, different structure
$xmlData["magazines"] = $xmlData->writtenMedia($xmlData->fashion($xmlData->work("shirts"), $xmlData->work("suits"), $xmlData->work("blouses")), $xmlData->tech($xmlData->work("gigakeys"), $xmlData->work("random access keyboards"), $xmlData->work("laundry and lint")), $xmlData->cooking($xmlData->work("vegetables"), $xmlData->work("bagels"), $xmlData->work("mexican")));
#same object, different structure
$xmlData["newspapers"] = $xmlData->writtenMedia($xmlData->local($xmlData->work("farmer bill"), $xmlData->work("effington daily"), $xmlData->work("high school")), $xmlData->national($xmlData->work("tabloid central"), $xmlData->work("politics the right way"), $xmlData->work("security and you")), $xmlData->scientific($xmlData->work("relativity"), $xmlData->work("obscurity"), $xmlData->work("obtuse")));
#same object, different structure
$xmlData["comics"] = $xmlData->writtenMedia($xmlData->superhero($xmlData->work("superpunch"), $xmlData->work("maggot person"), $xmlData->work("vunerable human")), $xmlData->manga($xmlData->work("squids and octopus"), $xmlData->work("ninjas and cowboys"), $xmlData->work("firballs and school girls")), $xmlData->strip($xmlData->work("the cashews"), $xmlData->work("kalvin cline"), $xmlData->work("diesel powered")));
#same object, different structure
$xmlData["blogs"] = $xmlData->writtenMedia($xmlData->news($xmlData->work("the post"), $xmlData->work("the site"), $xmlData->work("the post site")), $xmlData->photo($xmlData->work("mine"), $xmlData->work("my friend"), $xmlData->work("my dad")), $xmlData->video($xmlData->work("nsfw"), $xmlData->work("nsfw x 2"), $xmlData->work("nsfw duplicated x 4")));
//lets write these to a file for use later
file_put_contents("./drinks.xml", (string) $xmlDrinks);
//because these are in parts, they don't have the document headers appeneded to them
file_put_contents("./novels.xml", (string) $xmlData->stringWithDocumentHeader($xmlData["novels"]));
file_put_contents("./magazines.xml", (string) $xmlData->stringWithDocumentHeader($xmlData["magazines"]));
file_put_contents("./newspapers.xml", (string) $xmlData->stringWithDocumentHeader($xmlData["newspapers"]));
file_put_contents("./comics.xml", (string) $xmlData->stringWithDocumentHeader($xmlData["comics"]));
file_put_contents("./blogs.xml", (string) $xmlData->stringWithDocumentHeader($xmlData["blogs"]));
////////////////////////////////////////////////////////////////////////////////
// The MIT License (MIT)
//
// Copyright (c) 2013 Dodzi Dzakuma (http://www.nexocentric.com)
//