我找不到这些解析技术的比较.哪一个最常用?
问候.穆斯塔法
我正在尝试使用任何一个基于libxml的第三方XML解析器,但我不能,因为我认为我有某种类型的libxml2问题
我将其他链接器标志设置为-lxml2
和/ usr/include/libxml2的标题搜索路径
但是当我尝试编译时,我仍然会得到大量未定义的符号.以下错误是尝试编译TouchXML的结果.
Undefined symbols:
"_xmlDocDumpFormatMemory", referenced from:
-[CXMLDocument description] in CXMLDocument.o
"_xmlXPathNewContext", referenced from:
-[CXMLNode nodesForXPath:error:] in CXMLNode.o
-[CXMLNode(CXMLNode_NamespaceExtensions) nodesForXPath:namespaceMappings:error:] in CXMLNode_XPathExtensions.o
"_xmlOutputBufferFlush", referenced from:
-[CXMLNode XMLStringWithOptions:] in CXMLNode.o
"_xmlNodeListGetString", referenced from:
-[CXMLNode stringValue] in CXMLNode.o
"_xmlFree", referenced from:
_xmlFree$non_lazy_ptr in CXMLDocument.o
_xmlFree$non_lazy_ptr in CXMLNode.o
(maybe you meant: _xmlFree$non_lazy_ptr)
"_xmlXPathFreeContext", referenced from:
-[CXMLNode nodesForXPath:error:] in CXMLNode.o
-[CXMLNode(CXMLNode_NamespaceExtensions) nodesForXPath:namespaceMappings:error:] in CXMLNode_XPathExtensions.o
"_xmlNodeDumpOutput", referenced from:
-[CXMLNode XMLStringWithOptions:] in CXMLNode.o
"_xmlAddChild", referenced from:
-[CXMLDocument(CXMLDocument_CreationExtensions) addChild:] in CXMLDocument_CreationExtensions.o
-[CXMLElement(CXMLElement_CreationExtensions) addChild:] in …Run Code Online (Sandbox Code Playgroud) 我正在使用TouchXml,因为NSXML在实际的iPhone上存在限制.无论如何,我刚刚开始使用Objective-C,我来自C#背景,感觉就像在学习一些新东西......但是......这是我的xml文件......
<?xml version="1.0" encoding="utf-8"?>
<FundInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/webservices">
<FundsReleaseDate>2009-02-11T00:00:00</FundsReleaseDate>
<FundValue>7800</FundValue>
<FundShares>1000</FundShares>
</FundInfo>
Run Code Online (Sandbox Code Playgroud)
我想获得7800,即FundValue.有人点我在正确的方向,我现在用的是TouchXml CXMLDocument和myParser的类型是CXMLDocument的,我曾尝试
NSArray *nodes = [myParser nodesForXPath:@"//FundInfo" error:&err];
Run Code Online (Sandbox Code Playgroud)
基本上节点的评估结果为零
if ([nodes count] > 0 ) {
amount = [nodes objectAtIndex:1];
}
Run Code Online (Sandbox Code Playgroud)
更新1:我已经使用XPath放弃解析,并用的NSURLRequest取代它,所以现在我有一个字符串在整个XML,但我的粗鲁介绍客观-C继续...我只是意识到如何撒娇我已经成为了.NET BCL,像Regex这样的东西很容易获得.
UPDATE2:我已经想通了如何使用RegexKitLite的正则表达式.
所以,现在的问题是,我该如何获得"7800"由内FundValue现在是一个大的字符串.我已确认我有它在我的NSString使用NSLog的写它.
我刚刚将TouchXML添加到我的项目中,它告诉我:
警告:阻塞:/**/Classes/Creation是版本控制下的阻止项
同样,Tidy也是如此:
警告:阻塞:/**/Classes/Tidy是版本控制下的阻止项
这只是一个警告,但它非常烦人; 我怎么能摆脱它?
如何使用touchXML解析此XML?我想将所有属性存储为字典中的键/值对.
<Player PlayerName="Padraig HARRINGTON" CurrentPosition="1" CurrentRank="1"
Country="IRL" NumberOfHolesPlayed="18" ParRelativeScore="+3">
<RoundScore RoundNumber="1" Score="74" />
<RoundScore RoundNumber="2" Score="68" />
<RoundScore RoundNumber="3" Score="72" />
<RoundScore RoundNumber="4" Score="69" />
</Player>
<Player PlayerName="Ian POULTER" CurrentPosition="2" CurrentRank="2" Country="ENG"
NumberOfHolesPlayed="18" ParRelativeScore="+7">
<RoundScore RoundNumber="1" Score="72" />
<RoundScore RoundNumber="2" Score="71" />
<RoundScore RoundNumber="3" Score="75" />
<RoundScore RoundNumber="4" Score="69" />
</Player>
<Player PlayerName="Henrik STENSON" CurrentPosition="3" CurrentRank="T3" Country="SWE"
NumberOfHolesPlayed="18" ParRelativeScore="+9">
<RoundScore RoundNumber="1" Score="76" />
<RoundScore RoundNumber="2" Score="72" />
<RoundScore RoundNumber="3" Score="70" />
<RoundScore RoundNumber="4" Score="71" />
</Player>
Run Code Online (Sandbox Code Playgroud)
我没有问题是XML格式如下:
<Player>
<Country>UK</Country>
<NumberOfHolesPlayed>12</NumberOfHolesPlayed> …Run Code Online (Sandbox Code Playgroud) 我一直试图解析一个XHTMLdoc TouchXML,但它始终找不到任何标签XPath query.
以下是XHTML:
XHTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 25 March 2009), see www.w3.org" />
<title></title>
</head>
<body>
<p>
<a href="http://www.flickr.com/photos/55397648@N00/5987335786/"
title="casavermeer5.jpg by the style files, on Flickr">
<img src="http://farm7.static.flickr.com/6127/5987335786_abec990554_o.jpg"
width="500" height="750" border="0" alt="casavermeer5.jpg" />
</a>
</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
因此,我们可以看到有一个"p"标签,"a"标签和"img"标签
我所做的然后显示如下代码:
CXHTMLDocument *doc = [[[CXHTMLDocument alloc] initWithXHTMLString:XHTML options:0 error:&error] autorelease];
NSLog(@"error %@", [error localizedDescription]);
NSLog(@"doc children count = …Run Code Online (Sandbox Code Playgroud) 我试图看看它是如何工作的但是我现在似乎发现的只是死链接,支离破碎的评论或没有任何值得介绍初学者的东西?
欢迎任何指示,谢谢
TouchXML仍然可用吗?我找不到更新的下载源,要么很旧,要么找不到404 URL?
它不再可用吗?
我有一个具有以下结构的XML,我正在尝试从此创建我的模型对象.有人可以帮我找到一种方法,使用TouchXML,NSMutableArray和NSMutableDictionay从XML中获取这些对象.
<?xml version="1.0" encoding="utf-8"?>
<response>
<level1_items>
<level1_item>
<item_1>text</item_1>
<item_2>text</item_2>
</level1_item>
<level1_item>
<item_1>some text</item_1>
<item_2>some more text</item_2>
</level1_items>
<items>
<item>
<child_items>
<child_item>
<leaf1>node text</leaf1>
<leaf2>leaf text</leaf2>
<leaf3>some text</leaf3>
</child_item>
<child_item>
<leaf1>text</leaf1>
<leaf2>leaf text</leaf2>
<leaf3>more text</leaf3>
</child_item>
</child_items>
</item>
<item>
<child_items>
<child_item>
<leaf1>node text</leaf1>
<leaf2>leaf text</leaf2>
<leaf3>some text</leaf3>
</child_item>
<child_item>
<leaf1>text</leaf1>
<leaf2>leaf text</leaf2>
<leaf3>more text</leaf3>
</child_item>
</child_items>
</item>
</items>
</response>
Run Code Online (Sandbox Code Playgroud)
我需要解析它<response>和它的孩子.
我正在努力学习objective-c(我对此非常新)并且我在内存管理方面存在问题......
我正在开发一款使用TouchXML的iPad应用程序.
我创建了扩展CXMLDocument的类,并通过读取一些内容并保存到属性中进行初始化.
这是我的代码(SimpleManifest.h):
@interface SimpleManifest : CXMLDocument {
CXMLNode *_defaultOrganization;
NSString *_title;
NSDictionary *dictionary;
}
@property (readonly) CXMLNode *defaultOrganization;
@property (readonly) NSString* title;
- (id) initWithPath:(NSString *)path options:(NSUInteger)options error:(NSError **)error;
@end
Run Code Online (Sandbox Code Playgroud)
(SimpleManifest.m):
#import "SimpleManifest.h"
#import "CXMLNode_XPathExtensions.h"
@implementation SimpleManifest
- (id) initWithPath:(NSString *)path options:(NSUInteger)options error:(NSError **)error
{
/*
NSURL *theURL = [[[NSURL alloc] initFileURLWithPath:path] autorelease];
self = [self initWithContentsOfURL:theURL options:options error:error];
*/
NSData *data = [NSData dataWithContentsOfFile:path];
NSString *s = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
self = [self initWithXMLString:s options:options …Run Code Online (Sandbox Code Playgroud) touchxml ×10
iphone ×6
cocoa-touch ×3
ios ×3
xml ×3
libxml2 ×2
objective-c ×2
parsing ×2
gdata ×1
xcode4 ×1
xhtml ×1
xml-parsing ×1
xpath ×1