PDA

View Full Version : can processing instructions occur deeper than document children


wac
12-08-2004, 11:24 PM
I couldn't find where this would be documented. I'm trying to write a couple of processing instructions for include/exclude conditional processing. I need to be able to include/exclude various elements deep in the XML document and I thought processing instructions would be the ideal way to do this but I've been told that processing instructions should only occur as children of the root element. Also, to simplify things I would rather get them all at once and process them up front instead of embeding the PI handling during the node parsing. Any ideas???

Alex Vincent
12-09-2004, 03:42 AM
You can include processing instructions just about anywhere in the document. As far as I know, the only place they can't occur is before the XML declaration tag (which itself resembles a processing instruction).

Putting them inside comments, though, doesn't do much good. :)

As for processing them all up front, as you suggest: that's really up to the implementation that's reading the XML document.