<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The WebDevil &#187; XML</title>
	<atom:link href="http://dmitry.shaposhnik.name/category/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://dmitry.shaposhnik.name</link>
	<description>Enjoy development</description>
	<lastBuildDate>Mon, 24 May 2010 01:29:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP5 &amp;&amp; XML</title>
		<link>http://dmitry.shaposhnik.name/2006/09/14/php5-xml/</link>
		<comments>http://dmitry.shaposhnik.name/2006/09/14/php5-xml/#comments</comments>
		<pubDate>Thu, 14 Sep 2006 10:00:55 +0000</pubDate>
		<dc:creator>dm</dc:creator>
				<category><![CDATA[Newbie]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://0804team.kiev.ua/dm/blog/2006/09/14/php5-xml/</guid>
		<description><![CDATA[Итак, столкнулся я с задачей сгенерировать XML-документ. Довольно простой. Но я понял, что зря я не работал с XML раньше. Благо, в сети нашелся туториал, который замечтательно подошел мне. И на этом примере вполне можно освоить основы этой нехитрой генерации&#8230;

Найдено это было тут:
 http://weblog.bignerdranch.com/?p=8, все копирайты принадлежат их авторам. Сдесь же я вкратце приведу пример.
Надо [...]]]></description>
			<content:encoded><![CDATA[<p>Итак, столкнулся я с задачей сгенерировать XML-документ. Довольно простой. Но я понял, что зря я не работал с XML раньше. Благо, в сети нашелся туториал, который замечтательно подошел мне. И на этом примере вполне можно освоить основы этой нехитрой генерации&#8230;</p>
<p><span id="more-36"></span></p>
<p>Найдено это было тут:</p>
<p><a target="_blank" href="http://weblog.bignerdranch.com/?p=8"> http://weblog.bignerdranch.com/?p=8</a>, все копирайты принадлежат их авторам. Сдесь же я вкратце приведу пример.</p>
<p>Надо сделать такое:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt; ?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;iso-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;teams<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;team<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Atlanta Braves<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stadium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Turner Field<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stadium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;league<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>National<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/league<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/team<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;team<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Chicago Cubs<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stadium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Wrigley Field<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stadium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;league<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>National<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/league<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/team<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
...<br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;team<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Baltimore Orioles<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stadium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Camden Yards<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stadium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;league<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>American<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/league<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/team<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
...<br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/teams<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>И сделать его можно так:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// xml_teams_dom.php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// create the new XML document</span><br />
<span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1.0'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'iso-8859-1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// create the root element</span><br />
<span style="color: #000088;">$list_of_teams</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'teams'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$list_of_teams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// create the first team element</span><br />
<span style="color: #000088;">$team</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'team'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$list_of_teams</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$team</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// now create all the subelements for the team</span><br />
<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$team</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$name</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Atlanta Braves'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$stadium</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$team</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stadium'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$stadium</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Turner Field'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$league</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$team</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'league'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$league</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'National'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// create the second team element</span><br />
<span style="color: #000088;">$team</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'team'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$list_of_teams</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$team</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// now create all the subelements for the second team</span><br />
<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$team</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$name</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Chicago Cubs'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$stadium</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$team</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stadium'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$stadium</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Wrigley Field'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$league</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$team</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'league'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$league</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'National'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$xml_result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// simple mechanism to see the XML</span><br />
<br />
<span style="color: #b1b100;">print</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;&lt;</span>textarea name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;xml_result&quot;</span> rows<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;40&quot;</span> cols<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;80&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000088;">$xml_result</span> XML_SHOW<span style="color: #339933;">;</span> &nbsp;<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Собственно, мне было не столь важно описание, поскольку в теории все понятно, сколько практический пример.</p>
]]></content:encoded>
			<wfw:commentRss>http://dmitry.shaposhnik.name/2006/09/14/php5-xml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
