I have this problem, that I need to access processing instruction in MSXML IXMLDOMDocument2 interface.
Is it possible to do XMLDocument.load()
and have access to xml-stylesheet
instruction?
If it is, how to do it right?
I have xml with:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="transform.xsl"?>
...
and I need to extract xml-stylesheet
href
value.
But XMLDocument
seems to not contain this processing instruction after XMLDocument.load()
operation.
So than I can't perform:
XMLDocument.transformNode(XSLDocument);
with XSLDocument
being filled with what is inside transform.xsl
, because I don't know where transform.xsl
is being located.
Thanks for any help.
Assuming MSXML doesn't model the XML declaration as a node (I don't think it does but I am not sure) you should be able to access the processing instruction as XMLDocument.firstChild
and XMLDocument.firstChild.data
gives you then the "value" of the processing instruction, i.e. the complete string type="text/xsl" href="transform.xsl"
.
You should also be able to select the node using XPath and XMLDocument.selectSingleNode("processing-instruction('xml-stylesheet')").data
, only XPath is not the default selection language in MSXML 3 (only in MSXML 6) so for MSXML 3 you would need to first set XMLDocument.setProperty("SelectionLanguage", "XPath")
.