• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Weird Parsed HTML string into NSXMLDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird Parsed HTML string into NSXMLDocument


  • Subject: Weird Parsed HTML string into NSXMLDocument
  • From: Gustavo Pizano <email@hidden>
  • Date: Mon, 1 Feb 2010 15:01:07 +0100

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

  • Follow-Ups:
    • Re: Weird Parsed HTML string into NSXMLDocument
      • From: Gustavo Pizano <email@hidden>
  • Prev by Date: Tutorial for writing a bindings-compliant NSView subclass?
  • Next by Date: __weak references in non-GC
  • Previous by thread: Re: Tutorial for writing a bindings-compliant NSView subclass?
  • Next by thread: Re: Weird Parsed HTML string into NSXMLDocument
  • Index(es):
    • Date
    • Thread