I need 3 values (ExternalID, SystemID, InternalSubset) from xmlNodePtr when it is of type XML_DOCUMENT_TYPE_NODE or XML_DTD_NODE.
I noticed that XML_DOCUMENT_TYPE_NODE is deprecated and that you recommend using XML_DTD_NODE. Given, an xmlNodePtr which has type=XML_DOCUMENT_TYPE_NODE or XML_DTD_NODE, how can fetch those 3 values.
I also noticed that in Android Open Source Code here they have directly typecasted xmlNodePtr to xmlDtdPtr. Is this possible? If yes, we can get ExternalID and SystemID from xmlDtdPtr.
If the node type is
XML_DTD_NODE, simply cast
Thanks for answering.
Curious to know that since xmlDtdPtr and xmlNodePtr and two different structs with different members, during the cast, how does compiler initialise members like ExternalID, SystemID, notations, elements etc. which are not present in xmlNodePtr?
For DTD nodes, the struct is actually an xmlDtd whose address is then cast to an xmlNodePtr. So you’re just casting back to the original type. Some members like
type are in the same position, so they can be accessed regardless of type.
Thanks for the explanation.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.