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

NSXMLDocument

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

  1. macrumors member

    #1
    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

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

    Eraserhead

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

    #4
    write xml dynamically

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

    robbieduncan

    Staff Member

    #5
    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

    #6
    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
     
  7. Moderator

    robbieduncan

    Staff Member

    #7
    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

    #8
    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

    robbieduncan

    Staff Member

    #9
    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

    #10
    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

    robbieduncan

    Staff Member

    #11
    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

    #12
    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

    robbieduncan

    Staff Member

    #13
    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

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

    robbieduncan

    Staff Member

    #15

Share This Page