Re: Event-Driven XML Parsing and Entity References
Re: Event-Driven XML Parsing and Entity References
- Subject: Re: Event-Driven XML Parsing and Entity References
- From: Nathan Kinsinger <email@hidden>
- Date: Sun, 27 Jul 2008 15:13:56 -0600
On Jul 27, 2008, at 12:52 PM, Carter R. Harrison wrote:
There's been some discussion on this topic previously, but I haven't
been able to find the solution that I'm looking for. I'm using the
event-driven XML parser (CFXMLParser). Apparently it does not
support the replacement of entity references (&, <, >, etc..).
So assume I'm trying to parse the following XML tag:
<title>Planes, Trains, & Automobiles</title>
When the parser enters the <title> node, it calls the
createStructure callback function three times. Each time it has the
following data within the node that is passed in:
Call #1: "Planes, Trains, "
Call #2: "&"
Call #3: " Automobiles"
A similar thing happens in the addChild callback function.
I understand that I need to do manual replacement of the & with a
"&" in this case, but I still don't understand how I'm supposed to
maintain the state in between the three calls to createStructure and
addChild so that I can successfully concatenate all three text
segments together to form the original string (which is what I want
to store). I hope this makes sense - it's terribly frustrating.
As always, thanks in advance.
I haven't used CFXMLParser, but generally in event xml parsing you
keep adding to the string until the end of the element. Parsers may
break the element up into several parts and give them to you one at a
time.
In this case in either your addChild or createStructure functions you
would add the new parsed string to the child nodes existing string.
You may find more people with experience using CFXMLParser on the
Carbon dev list:
http://lists.apple.com/mailman/listinfo/carbon-dev
That said, this is the Cocoa dev list, have you looked at NSXMLParser?
http://developer.apple.com/documentation/Cocoa/Conceptual/XMLParsing/XMLParsing.html
--Nathan
_______________________________________________
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