This is a minimal XHTML 1.1 document.
\ 28 | \ 29 | "; 30 | } 31 | 32 | - (void)testBasicXHTML { 33 | RXMLElement *html = [RXMLElement elementFromHTMLString:simpleHTML_ encoding:NSUTF8StringEncoding]; 34 | NSArray *atts = [html attributeNames]; 35 | STAssertEquals(atts.count, 2U, nil); 36 | 37 | NSArray* children = [html childrenWithRootXPath:@"//html/body/p"]; 38 | STAssertTrue([children count] > 0, nil); 39 | 40 | RXMLElement* child = [children objectAtIndex:0]; 41 | NSLog(@"content: %@", [child text]); 42 | STAssertEqualObjects([child text], @"This is a minimal XHTML 1.1 document.", nil); 43 | } 44 | 45 | -(void) testHtmlEntity { 46 | RXMLElement* html = [RXMLElement elementFromHTMLString:@"Don't say "lazy"
" encoding:NSUTF8StringEncoding]; 47 | STAssertEqualObjects([html text], @"Don't say \"lazy\"", nil); 48 | } 49 | 50 | -(void) testFixBrokenHtml { 51 | RXMLElement* html = [RXMLElement elementFromHTMLString:@"Test
Broken HTML" encoding:NSUTF8StringEncoding]; 52 | STAssertEqualObjects([html text], @"Test Broken HTML", nil); 53 | STAssertEqualObjects([html xml], @"Test
Broken HTML", nil); 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Tests/SimpleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleTests.m 3 | // RaptureXML 4 | // 5 | // Created by John Blanco on 9/24/11. 6 | // Copyright (c) 2011 Rapture In Venice. All rights reserved. 7 | // 8 | 9 | #import "RXMLElement.h" 10 | 11 | @interface SimpleTests : SenTestCase { 12 | NSString *simplifiedXML_; 13 | NSString *attributedXML_; 14 | NSString *interruptedTextXML_; 15 | NSString *cdataXML_; 16 | NSString *treeXML_; 17 | } 18 | 19 | @end 20 | 21 | 22 | 23 | @implementation SimpleTests 24 | 25 | - (void)setUp { 26 | simplifiedXML_ = @"\ 27 |