Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read processing instruction from an XML file using .NET 3.5

How to check whether an Xml file have processing Instruction

Example

 <?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"?>

from the XML file.

Please help me to do this.

like image 353
Thorin Oakenshield Avatar asked Jun 23 '10 09:06

Thorin Oakenshield


1 Answers

How about:

XmlProcessingInstruction instruction = doc.SelectSingleNode("processing-instruction('xml-stylesheet')") as XmlProcessingInstruction;
like image 56
Garett Avatar answered Sep 22 '22 01:09

Garett