English 中文(简体)
• 如何将超文本与TIXML或其他一些替代物混为一谈
原标题:How to parse HTML with TouchXML or some other alternative

我试图将下文所述的超文本同TyXML混为一谈,但在我试图摘取某些属性时,它仍在坠毁。 我对古兰经世界说全新话,因此我道歉,因为我是一个完整的主人。 我需要帮助消除这一超文本。 我所要完成的是,将每个特性和价值,或哪些内容,或将其复制给扼杀。 我曾试图找到一个好的教区,以 par立超文,而我相信,Tydy是我所看到的最佳之兆。 说蒂迪语,我怎么能先通过提迪操作这种超文本? 我不知道如何做到这一点。 这里,我迄今为止制定的法典没有把我所需要的一切从超文本中删除。 任何帮助或建议都会受到高度赞赏。 增 编

我目前的法典:

NSMutableArray *res = [[NSMutableArray alloc] init];

//  using local resource file
NSString *XMLPath   = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"example.html"];
NSData *XMLData     = [NSData dataWithContentsOfFile:XMLPath];
CXMLDocument *doc   = [[[CXMLDocument alloc] initWithData:XMLData options:0 error:nil] autorelease];

NSArray *nodes = NULL;

nodes = [doc nodesForXPath:@"//div" error:nil];

for (CXMLElement *node in nodes) {
    NSMutableDictionary *item = [[NSMutableDictionary alloc] init];



    [item setObject:[[node attributeForName:@"id"] stringValue] forKey:@"id"];

    [res addObject:item];
    [item release];
}


NSLog(@"%@", res);
[res release];

需加以分类的超文本文档:

<html> 
<head> 
<base target="_blank" /> 
</head> 
<body style="margin:2;"> 
<div id="group"> 
<div id="groupURL"><a href="http://www.example.com/groups">Group URL</a></div> 
<img id="grouplogo" src="http://images.example.com/groups/image.png" /> 
<div id="groupcomputer"><a href="http://www.example.com/groups/page" title="Group Title">Group title this would be here</a></div> 
<div id="groupinfos"> 
    <div id="groupinfo-l">Person</div><div id="groupinfo-r">Ralph</div> 
    <div id="groupinfo-l">Years</div><div id="groupinfo-r">4 years</div> 
    <div id="groupinfo-l">Salary</div><div id="groupinfo-r">100K</div> 
    <div id="groupinfo-l">Other</div><div id="groupoth" style="width:15px">other info</div> 
</body> 
</html>

EDIT:我可以使用Element Parser,但我需要知道如何从下面的例子中摘取个人姓名。

<div id=“groupinfo-l”>Person</div><div id=“groupinfo-r”>Ralph</div>

最佳回答

我不知道你是否犯过错,但我建议你使用,即XML的最佳教程和超文本。 希望这一帮助。

问题回答

暂无回答




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签