<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Node code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 17:49:36 GMT</pubDate>
    <description>DZone Snippets: Node code</description>
    <item>
      <title>Count the no of elements in an XML node</title>
      <link>http://snippets.dzone.com/posts/show/4939</link>
      <description>This Ruby code count the no. of elements in an xml node by converting the children into an array and then returning the length.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'rexml/document'&lt;br /&gt;include REXML&lt;br /&gt;&lt;br /&gt;file = File.new('test.xml')&lt;br /&gt;doc = Document.new(file)&lt;br /&gt;puts doc.root.elements.to_a.length&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 02 Jan 2008 00:32:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4939</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Getting Results for Paged Display</title>
      <link>http://snippets.dzone.com/posts/show/4807</link>
      <description>We can present these blog entries a better way: as a page of formatted results with links to more&lt;br /&gt;results. We can do that using Drupal&#8217;s pager. Let&#8217;s grab all of the blog entries again, only this&lt;br /&gt;time we&#8217;ll display them as a paged result, with links to additional pages of results and &#8220;first and&lt;br /&gt;last&#8221; links at the bottom of the page.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$sql = "SELECT * FROM {node} n WHERE type = 'blog' AND status = 1 ORDER BY&lt;br /&gt;n.created DESC"&lt;br /&gt;$result = pager_query(db_rewrite_sql($sql), 0, 10);&lt;br /&gt;while ($data = db_fetch_object($result)) {&lt;br /&gt;$node = node_load($data-&gt;nid);&lt;br /&gt;print node_view($node, TRUE);&lt;br /&gt;}&lt;br /&gt;// Add links to remaining pages of results.&lt;br /&gt;print theme('pager', NULL, 10);&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 21 Nov 2007 12:57:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4807</guid>
      <author>bifurcafe (Alex)</author>
    </item>
    <item>
      <title>Actionscript _XML Class</title>
      <link>http://snippets.dzone.com/posts/show/3513</link>
      <description>&lt;code&gt;&lt;br /&gt;import _String;&lt;br /&gt;&lt;br /&gt;dynamic class _XML extends XML {&lt;br /&gt;	function _XML() {&lt;br /&gt;		&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public function $N(tag,xmlNode,xmlNodeArray){&lt;br /&gt;		if (xmlNode == undefined) var xmlNode = this;&lt;br /&gt;		if (xmlNodeArray == undefined) var xmlNodeArray:Array = new Array();&lt;br /&gt;		var nodeArray:Array = new Array();&lt;br /&gt;		&lt;br /&gt;		for (var x=0; x&lt;xmlNode.childNodes.length; x++) {&lt;br /&gt;			if (xmlNode.childNodes[x].nodeType == 1){&lt;br /&gt;				if (xmlNode.childNodes[x].nodeName == tag) xmlNodeArray.push(xmlNode.childNodes[x]);&lt;br /&gt;				$N(tag,xmlNode.childNodes[x],xmlNodeArray);&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;		return xmlNodeArray;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	// If multiple, returns a nodeValue Array&lt;br /&gt;	// If single, returns a nodeValue String&lt;br /&gt;	public function $V(tag,xmlNode) {&lt;br /&gt;		if (xmlNode == undefined) var xmlNode = this;&lt;br /&gt;		var n = $N(tag,xmlNode);&lt;br /&gt;		if (n.length == 1){&lt;br /&gt;			var nV = n[0].firstChild.nodeValue;&lt;br /&gt;			if (nV != undefined){&lt;br /&gt;				nV = escape(nV);&lt;br /&gt;				nV = _String.Replace(nV,"%C2%93","%22");&lt;br /&gt;				nV = _String.Replace(nV,"%C2%94","%22");&lt;br /&gt;				nV = unescape(nV);&lt;br /&gt;			}&lt;br /&gt;			return nV;&lt;br /&gt;		}&lt;br /&gt;		else {&lt;br /&gt;			var vArray:Array = new Array();&lt;br /&gt;			for (var i:String in n) {&lt;br /&gt;				vArray[i] = n[i].firstChild.nodeValue;&lt;br /&gt;				if (vArray[i] != undefined){&lt;br /&gt;					vArray[i] = escape(vArray[i]);&lt;br /&gt;					vArray[i] = _String.Replace(vArray[i],"%C2%93","%22");&lt;br /&gt;					vArray[i] = _String.Replace(vArray[i],"%C2%94","%22");&lt;br /&gt;					vArray[i] = unescape(vArray[i]);&lt;br /&gt;				}&lt;br /&gt;			}&lt;br /&gt;			return vArray;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 13 Feb 2007 19:32:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3513</guid>
      <author>bgidge (Bryan Gidge)</author>
    </item>
  </channel>
</rss>
