<?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>以太之内 生存之上 &#187; xml</title> <atom:link href="http://ixhan.com/tag/xml/feed/" rel="self" type="application/rss+xml" /><link>http://ixhan.com</link> <description>Live in your world, get owned in mine</description> <lastBuildDate>Tue, 15 May 2012 04:08:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Tutorial of  kissXML(iPhone)</title><link>http://ixhan.com/2010/03/tutorial-of-kissxml-iphone/</link> <comments>http://ixhan.com/2010/03/tutorial-of-kissxml-iphone/#comments</comments> <pubDate>Wed, 24 Mar 2010 17:27:44 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[iOS]]></category> <category><![CDATA[c]]></category> <category><![CDATA[google]]></category> <category><![CDATA[kissxml]]></category> <category><![CDATA[png]]></category> <category><![CDATA[Project]]></category> <category><![CDATA[tutorial]]></category> <category><![CDATA[work]]></category> <category><![CDATA[xml]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=289</guid> <description><![CDATA[<a
href="http://ixhan.com/2010/03/tutorial-of-kissxml-iphone/" title="Tutorial of  kissXML(iPhone)"></a>KissXML is a good approach for parsing xml data, and the x-path function make it more powerful. Integrate With You Project And KissXML Download source codes form here Add all the files to your project (excluding DDXMLTesting) Configure you project &#8230;<p
class="read-more"><a
href="http://ixhan.com/2010/03/tutorial-of-kissxml-iphone/">Read more &#187;</a></p>]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2010/03/tutorial-of-kissxml-iphone/" title="Tutorial of  kissXML(iPhone)"></a><p>KissXML is a good approach for parsing xml data, and the x-path function make it more powerful.</p><h3>Integrate With You Project And KissXML</h3><ul><li>Download source codes form <a
target="_blank" href="http://kissxml.googlecode.com/files/KissXML.zip">here</a></li><li>Add all the files to your project (excluding DDXMLTesting)</li><li>Configure you project to work with libxml</li></ul><p>click Project -&gt; Edit Project Settings</p><p>You&#8217;ll be adding this to your compiler instructions</p><p>OTHER_LDFLAGS = -lxml2</p><p>HEADER_SEARCH_PATHS = /usr/include/libxml2</p><p><img
class="alignnone" src="http://www.deusty.com/blog/KissXML/XcodeSetup3.png" alt="" width="511" height="538" /></p><h3>Using KissXML</h3><p>Here is a quick demo to indicate you how it works.</p><p>For example, we need to get the SRC value of each media field from the target xml file.</p><pre class="brush: xml; title: ; notranslate">
&lt;smil xmlns=&quot;http://www.w3.org/2000/SMIL20/CR/Language&quot;&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;par dur=&quot;120000ms&quot; &gt;
&lt;text region=&quot;Text&quot; src=&quot;att000.txt&quot; /&gt;
&lt;/par&gt;
&lt;par dur=&quot;120000ms&quot; &gt;
&lt;text region=&quot;Text&quot; src=&quot;att010.txt&quot; /&gt;
&lt;/par&gt;
&lt;par dur=&quot;10000ms&quot; &gt;
&lt;img region=&quot;Image&quot; src=&quot;att020.jpg&quot;/&gt;
&lt;/par&gt;
&lt;par dur=&quot;120000ms&quot; &gt;
&lt;text region=&quot;Text&quot; src=&quot;att040.txt&quot; /&gt;
&lt;/par&gt;
&lt;par dur=&quot;10000ms&quot; &gt;
&lt;img region=&quot;Image&quot; src=&quot;att120.gif&quot;/&gt;
&lt;/par&gt;
&lt;/body&gt;
&lt;/smil&gt;
</pre><p>Here are the codes !</p><pre class="brush: objc; title: ; notranslate">
//hack to remove xmlns =&gt; avoid xpath search not works
 xmlStr = [xmlStr stringByReplacingOccurrencesOfString:@&quot;xmlns&quot; withString:@&quot;noNSxml&quot;];
 NSMutableArray* contents = [NSMutableArray array];
 NSError* error = nil;
 DDXMLDocument* xmlDoc = [[DDXMLDocument alloc] initWithXMLString:xmlStr options:0 error:&amp;error];
 if (error) {
 NSLog(@&quot;%@&quot;,[error localizedDescription]);
 return nil;
 }
 NSArray* resultNodes = nil;
 resultNodes = [xmlDoc nodesForXPath:@&quot;//audio | //text | //image | //img&quot; error:&amp;error];
 if (error) {
 NSLog(@&quot;%@&quot;,[error localizedDescription]);
 return nil;
 }
 for(DDXMLElement* resultElement in resultNodes)
 {
 NSString* name = [resultElement name];
 //audio , text or other media type
 NSString* fileName = [[resultElement attributeForName:@&quot;src&quot;] stringValue];
 // 0.txt
 }
</pre><p>Note, I replaced the &#8220;xmlns&#8221; inside the xml file, because it weird xpath would failed if namespace available at a XML file(it might a bug)</p><p>And at last, have fun!</p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2009/11/things-ive-done-in-past-5-months/" title="Things I&#8217;ve done int past 5 months">Things I&#8217;ve done int past 5 months</a></li><li><a
href="http://ixhan.com/2010/05/now-or-never/" title="now or never">now or never</a></li><li><a
href="http://ixhan.com/2009/10/convert-iphone-png-to-origin/" title="将编译好的iPhone程序的PNG还原">将编译好的iPhone程序的PNG还原</a></li><li><a
href="http://ixhan.com/2009/10/redmine-images-manager-system/" title="用 Redmine 管理iPhone项目中过多的图片文件">用 Redmine 管理iPhone项目中过多的图片文件</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2010/03/tutorial-of-kissxml-iphone/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
