• 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
Re: CFXMLNodeGetString() chokes on "&", "<" or ">"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFXMLNodeGetString() chokes on "&", "<" or ">"


  • Subject: Re: CFXMLNodeGetString() chokes on "&", "<" or ">"
  • From: Sherm Pendley <email@hidden>
  • Date: Sat, 11 Sep 2004 23:54:22 -0400

On Sep 11, 2004, at 9:46 PM, Jerry Krinock wrote:

and got the following output:

parse ok
type=4, string="xml"
type=2, string="foo"
   type=2, string="string"
      type=6, string="you "
      type=10, string="amp"
      type=6, string=" me"

CFXMLTreeCreateFromData breaking up the string "you & me" into three
strings. Fred's example (and my program) access only the first of these
strings; that's why we miss the "& me".


I would much appreciate some opinions from those smarter than me: Is this
behavior from CFXMLTreeCreateFromData expected, or is it a bug???

It's expected. "&amp;" is a physical entity, as is indicated by its type. The name of the entity is "amp", which is what's in the value string shown above.


The kCFXMLParserReplacePhysicalEntities and possibly the kCFXMLParserResolveExternalEntities options look like they might be useful for expanding entities into strings for you, but they're listed in the docs as unsupported.

On the odd chance that it's supported now, but the docs are lagging behind, you might try or-ing one (or both) of these option flags with the one you're already using, like this:

tree=CFXMLTreeCreateFromData(NULL,dat,NULL,kCFXMLParserSkipWhitespace,k CFXML
NodeCurrentVersion);

tree=CFXMLTreeCreateFromData(NULL,dat,NULL, kCFXMLParserSkipWhitespace | kCFXMLParserReplacePhysicalEntities, kCFXMLNodeCurrentVersion);

For more (lots more) about XML entities and entity expansion, see the section of the <http://w3c.org> site concerning XML, or any good book about it.

sherm--

_______________________________________________
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: CFXMLNodeGetString() chokes on "&", "<" or ">"
      • From: Jerry Krinock <email@hidden>
References: 
 >Re: CFXMLNodeGetString() chokes on "&", "<" or ">" (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Bindings not staying in sync when using NSPopUpButton selectItemWithTitle
  • Next by Date: spreadsheet editor
  • Previous by thread: Re: CFXMLNodeGetString() chokes on "&", "<" or ">"
  • Next by thread: Re: CFXMLNodeGetString() chokes on "&", "<" or ">"
  • Index(es):
    • Date
    • Thread