1. Welcome to the new MacRumors forums. See our announcement and read our FAQ


Discussion in 'iPhone/iPad Programming' started by shilpa, Jun 26, 2008.

  1. macrumors member

    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.
  2. macrumors 65816

    Any luck on this I'm getting the same error.
  3. macrumors G4


    What are you trying to do exactly?
  4. macrumors newbie

    write xml dynamically


    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.

  5. Moderator


    Staff Member

    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.
  6. macrumors newbie

    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.


  7. Moderator


    Staff Member

    Have you read the documentation? One potential option is discussed in this document. If performance is critical you might consider using libxml directly
  8. macrumors newbie

    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?
  9. Moderator


    Staff Member

    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 which should let you do what you want.
  10. macrumors newbie

    How could I use libxml2 to write a xml file? Could you please provide me any tutorial link or sample code for this?
  11. Moderator


    Staff Member

    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.
  12. macrumors newbie

    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.
  13. Moderator


    Staff Member

    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.
  14. macrumors regular

    Why not just write out the xml in a string? and then write that to a file?
  15. Moderator


    Staff Member


Share This Page