Re: Weird Parsed HTML string into NSXMLDocument
Re: Weird Parsed HTML string into NSXMLDocument
- Subject: Re: Weird Parsed HTML string into NSXMLDocument
- From: Gustavo Pizano <email@hidden>
- Date: Mon, 1 Feb 2010 17:23:59 +0100
[SOVED]
Hello, sometimes I curse myself for not trying harder before posting.
I just initialized the xmlDoc with options NSXMLPreserveCDATA and NSXMLDCocument TidHML..
then I was accessing nodes from the rootNode, and I could see in debug all.
Gustavo
On Feb 1, 2010, at 3:01 PM, Gustavo Pizano wrote:
> Hello all:
>
> I have a string with the html I created, i the following:
> <!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 http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> <title>Untitled Document</title>
> </head>
> <body style="width:100%"><div style="margin-right:auto;margin-left:auto; width:962px;"><div class="XWSDefaultHorizontalLayout" style="width:960px;height:100px;position:relative;"></div>
> </div></body></html>
>
> when parsing Im doing the following:
>
> NSXMLDocument * xmlDoc = [[[NSXMLDocument alloc] initWithXMLString:[webDic valueForKey:XWSHTMLKey] options:NSXMLDocumentXHTMLKind error:&xmlError] autorelease];
> if(xmlError){
> *error = [[NSError alloc] initWithDomain:NSOSStatusErrorDomain code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"There was a problem loading the XMLDocument for reason: %@",[xmlError localizedDescription]], NSLocalizedDescriptionKey,nil]];
> return nil;
> }
> else {
> //I have a well formated NSXMLDocuemnt;
> NSXMLElement * root = [xmlDoc rootElement];
> NSXMLElement * bodyElement = [[root elementsForName:@"body"] objectAtIndex:0];
> NSXMLDocument *bodyDoc =[[NSXMLDocument alloc] initWithRootElement:root];
> NSLog(@"here");
> }
>
> The last lines I put them to check the contents of the XMLDocument, BUT I have the following:
> 1-the rootElement its the <html ... > ... </html> which seems ok.
> 2. when I go int o the _children of the root, I have 2 children. the <head> and the <body>, if I check the head, this ones has 2 children, which are <meta> and <title>, smells ok for me.
> 3. BUT then when I check the <body> child, and I want to check its children, I see that the array wasn't initialized, it contains no children, it has the the _namespace the style, and thats it.
>
> Can somebody tell me what Im doing wrong?, I tryed to change the options parameter for something else, but the same behavior, even worst because I can't access the _namespaces.
>
> Thanks a lot for your help
>
> Gustavo Pizano
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden