PDA

View Full Version : NSXMLDocument




shilpa
Jun 26, 2008, 07:36 AM
Hi all,
I am creating xmldocument using NSXMLDocument.Application work fine in simulator.But when i build it for device i am getting errors that (NSXMLDocument *root) NSXMLDocument is undecleared,even NSXMLNode and NSXMLElement are undecleared it is showing.so please help.



detz
Jul 11, 2008, 11:57 AM
Any luck on this I'm getting the same error.

Eraserhead
Jul 11, 2008, 01:14 PM
What are you trying to do exactly?

sapplesystems
Dec 1, 2009, 03:57 AM
Hi

I am tring to create a xml file dynamically through my code using NSXMLElement and NSXMLDocument. But compiler displaying me the error that NSXMLElement and NSXMLDocument are undefined.

Can any one help in this.

Thanks in advance.

Gaurav

robbieduncan
Dec 1, 2009, 05:04 AM
I will assume this is an iPhone question. If it is then the answer is NSXMLDocument does not exist on the iPhone so don't use it. It's not in the iPhone Developer Center documentation so you should have already known this.

Yes it works in the simulator as that is using the libraries on your Mac but that does not mean it works on an iPhone. Stick to using the APIs declared by Apple.

sapplesystems
Dec 1, 2009, 05:39 AM
Ok Thanks for your support.

I am pretty new to Iphone development. So can you please tell me which API should I use to write a xml file dynamically.

Thanks

Gaurav

robbieduncan
Dec 1, 2009, 05:42 AM
Ok Thanks for your support.

I am pretty new to Iphone development. So can you please tell me which API should I use to write a xml file dynamically.

Thanks

Gaurav

Have you read the documentation? One potential option is discussed in this document (http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/XMLParsing/Articles/ConstructingTrees.html#//apple_ref/doc/uid/20002268). If performance is critical you might consider using libxml directly

sapplesystems
Dec 1, 2009, 06:09 AM
Thanks for your support

But it seems to me that the above document is related with How can we Parse the existing document. But I want to create a new xml file.

Could I do the same with XMLParser class?

robbieduncan
Dec 1, 2009, 06:48 AM
Thanks for your support

But it seems to me that the above document is related with How can we Parse the existing document. But I want to create a new xml file.

Could I do the same with XMLParser class?

Sorry: my initial scan of that document had me believing it was about using hte Parser to create a document. It's not.

If you don't want to use libxml2 directly (it's on the phone so you can use it) you could look at Google's replacement for NSXMLDocument (http://notes.bikemonkey.org/post/47351363/googles-nsxmldocument-replacement-for-iphone) which should let you do what you want.

sapplesystems
Dec 1, 2009, 06:55 AM
How could I use libxml2 to write a xml file? Could you please provide me any tutorial link or sample code for this?

robbieduncan
Dec 1, 2009, 07:02 AM
Are you so lazy that you can't use Google? Or do you just expect life to spoon-feed you results with no effort?

The first search result in Google for "libxml2 write to file" links to a page of examples, the first of which seems to do what you want.

sapplesystems
Dec 1, 2009, 07:47 AM
I am not lazy neither I want spoon feeding. I had already visited this page but the issue is I am not able to understand how could I use this code because it seems to me a php script.

robbieduncan
Dec 1, 2009, 07:58 AM
I am not lazy neither I want spoon feeding. I had already visited this page but the issue is I am not able to understand how could I use this code because it seems to me a php script.

testWriter.c is (as the file extension suggests) a pure C program. If it looks like PHP then you have serious issues as you should have a good knowledge of C before writing anything for the iPhone.

skunkworker
Dec 1, 2009, 09:46 PM
Why not just write out the xml in a string? and then write that to a file?

robbieduncan
Dec 10, 2009, 01:25 PM
Maybe newly released wrapper (http://acaciatreesoftware.com/blog/2009/12/atsgenx-released/) is helpful?