如何读取使用.NET 3.5 XML文件处理指令指令、文件、NET、XML

2023-09-07 02:40:58 作者:姐是限量版╮你爱要不要

如何检查XML文件是否有处理指令

How to check whether an Xml file have processing Instruction

示例

 <?xml-stylesheet type="text/xsl" href="Sample.xsl"?>

 <Root>
    <Child/>
 </Root>

我需要阅读的处理指令

I need to read the processing instruction

<?xml-stylesheet type="text/xsl" href="Sample.xsl"?>

从XML文件中。

from the XML file.

请帮我做这件事。

推荐答案

怎么样:

XmlProcessingInstruction instruction = doc.SelectSingleNode("processing-instruction('xml-stylesheet')") as XmlProcessingInstruction;