Monthly Archives: March 2010

开饭日[转自阿杰的QQ空间]

据野史记载,开饭日起源于亚洲东方的中国的互联网中生代的白垩纪,由于那时网络处于蛮荒时代,鸭嘴龙横行,吞噬龙间一切能够“自由”活动的东西,直到有一天,发现没有东西可进食,于是集合到一个叫“梅梯”的石头上,以“集体”之力量发出电波,向“背汉”星人友人传达“我们要开饭”的求助信息。背汉星人于是用特快彗星送来食物,不料救友心切,操作出了故障。。。为了纪念当日,网龙们自发地约定用“开饭日”来纪念这天 - 3月23日。 Read more »

Tutorial of kissXML(iPhone)

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 to work with libxml

click Project -> Edit Project Settings

You’ll be adding this to your compiler instructions

OTHER_LDFLAGS = -lxml2

HEADER_SEARCH_PATHS = /usr/include/libxml2

Using KissXML

Here is a quick demo to indicate you how it works.

For example, we need to get the SRC value of each media field from the target xml file.

<smil xmlns="http://www.w3.org/2000/SMIL20/CR/Language">
<head>
</head>
<body>
<par dur="120000ms" >
<text region="Text" src="att000.txt" />
</par>
<par dur="120000ms" >
<text region="Text" src="att010.txt" />
</par>
<par dur="10000ms" >
<img region="Image" src="att020.jpg"/>
</par>
<par dur="120000ms" >
<text region="Text" src="att040.txt" />
</par>
<par dur="10000ms" >
<img region="Image" src="att120.gif"/>
</par>
</body>
</smil>

Here are the codes !

//hack to remove xmlns => avoid xpath search not works
 xmlStr = [xmlStr stringByReplacingOccurrencesOfString:@"xmlns" withString:@"noNSxml"];
 NSMutableArray* contents = [NSMutableArray array];
 NSError* error = nil;
 DDXMLDocument* xmlDoc = [[DDXMLDocument alloc] initWithXMLString:xmlStr options:0 error:&error];
 if (error) {
 NSLog(@"%@",[error localizedDescription]);
 return nil;
 }
 NSArray* resultNodes = nil;
 resultNodes = [xmlDoc nodesForXPath:@"//audio | //text | //image | //img" error:&error];
 if (error) {
 NSLog(@"%@",[error localizedDescription]);
 return nil;
 }
 for(DDXMLElement* resultElement in resultNodes)
 {
 NSString* name = [resultElement name];
 //audio , text or other media type
 NSString* fileName = [[resultElement attributeForName:@"src"] stringValue];
 // 0.txt
 }

Note, I replaced the “xmlns” inside the xml file, because it weird xpath would failed if namespace available at a XML file(it might a bug)

And at last, have fun!

经不住的似水流年

如题.

文字少了点,贴个图.

PS. wiki系统重新回来了!!(页面右上角的NOTE),这一个多月的时间内被广告攻陷了,今天费了好久才整回来.新增加两个关于MediaWiki的note.

===== 觉得太标题党了点,更新点内容  =========

最近保持了很长一段时间的迷茫,之前做事想来是跟着感觉走,用李开复装逼的方法说就是follow my heart ,决定了也就义无反顾了. 现在发生的事却让我开始怀疑起自己的决定.如何才能做一个好的决定?

过去的一年里认识了3个人.

第一个人推荐了我本书 Programming Game AI by example

第二个人送了我本书 The beauty of code

第三个人推荐了本书 More joel on software

经历了不少,成功的失败的,学到很多.甚至还没来得及给2010年企划,居然已经过去1/4年了.

以后会花更多时间在思考上,而不是鲁莽行事.