Re: [xml] xmlNodeGetContent() for XML_ENTITY_REF_NODE

On Thu, Feb 21, 2002 at 06:02:54PM +0100, Henke, Markus wrote:

with regard to
i'm trying to collect the content of a XML_ELEMENT_NODE without
consider the child-XML_ELEMENT_NODEs.
I'm wondering if it's intended that 'xmlNodeGetContent(myNode)'
generally results 'NULL' if 'myNode' is a XML_ENTITY_REF_NODE?
And if so, what's the appropriate method to get the (expanded)
content of a  XML_ENTITY_REF_NODE?

   Get the ENTITY_DEF by doing an entity lookup for the entity
with that name, concatenate the xmlNodeGetContent() of its 
children. I'm not sure you can get this recursive. Another way would
be to change xmlNodeGetContent() behaviour on entities nodes.

Another point: I've debugged my code to see what happens
and found that a node with type XML_ENTITY_REF_NODE
holds the expanded entity in it's 'content' component,

  Actually it's a pointer to the associated ENTITY_DEF
node content's, the subtree are shared.

although i've set 'xmlSubstituteEntitiesDefault(0)'.
Is this correct?

  yes, with xmlSubstituteEntitiesDefault(1) you would get the content
directly instead of the reference node.
  xmlSubstituteEntitiesDefault(0) means the tree keeps track of the
entities in the document (including in attribute values !) so it can
save them back. xmlSubstituteEntitiesDefault(1) wipe them out and
substitute them with their content.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]