Re: NSXMLDocument question
Re: NSXMLDocument question
- Subject: Re: NSXMLDocument question
- From: malcom <email@hidden>
- Date: Sun, 5 Mar 2006 15:21:01 +0100
I've found another solution.
Just add this line when you create an NSXMLDocument
[xmlDoc setMIMEType:@"text/xml"];
It seems to works fine.
Thanks to all :)
On 3/5/06, Jim Correia <email@hidden> wrote:
> On Mar 4, 2006, at 11:29 AM, malcom wrote:
>
> > This is a short part of my code. Is there another way to convert
> > automatically <? Or need I do to it with replace functions of
> > NSString?
>
> [...]
>
> > NSXMLElement *quoteNode = [[NSXMLElement alloc]
> > initWithKind:
> > NSXMLElementKind options:NSXMLNodePreserveAll];
> > [quoteNode setName: @"QUOTE"];
> > [quoteNode setStringValue: [NSString
> > stringWithFormat:@"%d", [[_text
> > objectAtIndex:k] state]]];
>
> It seems like you are going out of your way to make things more
> difficult than they need to be. Using the NSXMLElement convenience
> methods, and you'll the the right answer as an added bonus.
>
> NSXMLElement *rootElement = [NSXMLNode elementWithName: @"root"];
> NSXMLDocument *xmlDocument = [NSXMLNode documentWithRootElement:
> rootElement];
>
> NSXMLElement *subElement = [NSXMLNode elementWithName: @"subelement"
> stringValue: @"<?"];
> [rootElement addChild: subElement];
>
> NSData *xmlData = [xmlDocument XMLData];
> NSString *xmlString = [[[NSString alloc] initWithData: xmlData
> encoding:NSUTF8StringEncoding] autorelease];
> NSLog(@"%@", xmlString);
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
www.malcom-mac.com
mac/win software development
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden