Re: How do I Allow empty attributes when parsing with XMLParseDataRef
Re: How do I Allow empty attributes when parsing with XMLParseDataRef
- Subject: Re: How do I Allow empty attributes when parsing with XMLParseDataRef
- From: Keary Suska <email@hidden>
- Date: Wed, 11 Jun 2008 17:53:54 -0600
- Thread-topic: How do I Allow empty attributes when parsing with XMLParseDataRef
6/11/08 3:07 AM, also sprach email@hidden:
> XMLParseDataRef
>
> to parse xml, but the parse does not accept empty attributes:
>
> My code look like this:
>
> sXMLStartElementUPP =
> (StartElementHandlerUPP)NewStartElementHandlerUPP(StartElementHandler);
> sXMLEndElementUPP =
> (EndElementHandlerUPP)NewEndElementHandlerUPP(EndElementHandler);
> sXMLCharHandlerUPP =
> (CharDataHandlerUPP)NewCharDataHandlerUPP(CharHandler);
>
> err = OpenADefaultComponent(xmlParseComponentType,
> xmlParseComponentSubType, &xmlParser);
> if (err == noErr) {
> XMLParseSetEventParseRefCon(xmlParser, (long) rec);
>
> XMLParseSetStartElementHandler(xmlParser, sXMLStartElementUPP);
> XMLParseSetCharDataHandler(xmlParser, sXMLCharHandlerUPP);
> XMLParseSetEndElementHandler(xmlParser, sXMLEndElementUPP);
>
> err = XMLParseDataRef(xmlParser, hdataref,
> HandleDataHandlerSubType, xmlParseFlagEventParseOnly |
> xmlParseFlagAllowUnquotedAttributeValues, NULL);
>
> I get the error - 2158, when parsing this:
> <page-status default="">
> <name>Proofreading</name>
>
> How do I tell the parser that is is ok with empty attribute strings?
> Is there a "parseflag" for this or do I need to use another parser?
If you don't need QuickTime in your app, you probably should be using
NSXMLParser (as suggested). Or maybe use it anyway as it may be more robust.
At least it returns more specific errors.
Are you certain that the issue is with the empty attribute? I.e., if you
specify a value, does the parser not choke? I ask because, AFAIK, an empty
attribute is legal, unless the attribute was declared as required.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden