• 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
Creating a valid XML header?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating a valid XML header?


  • Subject: Creating a valid XML header?
  • From: "a.d. jensen" <email@hidden>
  • Date: Mon, 7 Nov 2005 09:27:27 -0600

I'm creating an XML file programmatically, and must be missing a little something, because the header is invalid.

----

Here's the code:

NSXMLElement *root = (NSXMLElement *)[NSXMLNode elementWithName:@"contactList"];
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithRootElement:root];
[xmlDoc setVersion:@"1.0"];
[xmlDoc setCharacterEncoding:@"UTF-8"];
NSXMLDTD *theDTD = [NSXMLDTD alloc];
[theDTD setSystemID:@"http://www.mywebsite.com/XMLSpecs/ mysample.dtd"];
[xmlDoc setDTD:theDTD];


This results in an XML file that looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE  SYSTEM "http://www.mywebsite.com/XMLSpecs/mysample.dtd";>

<contactList>
    <contact>
        <firstName>Sample Contact</firstName>

        [ etc, etc, etc ]

    </contact>
</contactList>

----

The "<!DOCTYPE" line is missing the word "contactList" between "DOCTYPE" and "SYSTEM" (at least through my reading of the XML spec, and typing it in results in a valid XML file, at least as parsed by the program "Oxygen", which I'm using to validate.)

Any idea how to get it in there? The sample code that Apple provides for creating XML (photoSlideShow) doesn't generate valid XML either, skipping the "<!DOCTYPE" line entirely.


dale

--
email@hidden   http://adjensen.aatrix.com

Only a fool turns away from an angel,
Vision in white steps through the door,
Holds out her hand, I say 'No I'm not ready'
I open my eyes and let the dream fade away.
  -- echolyn, "on any given nite"


_______________________________________________ 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
  • Follow-Ups:
    • Re: Creating a valid XML header?
      • From: Jim Correia <email@hidden>
  • Prev by Date: Re: programmatic nib
  • Next by Date: Re: programmatic nib
  • Previous by thread: [Solved] How does Cocoa identify itself to a web server?
  • Next by thread: Re: Creating a valid XML header?
  • Index(es):
    • Date
    • Thread