c# - How can I get the href attribute value out of an <?xml-stylesheet> node? -


We are getting an XML document from a vendor, which requires transforming the XSL when we use their stylesheet So that we can convert the result HTML to the PDF into the XML document in ? Xml-stylesheet is defined in the definition of a href attribute. Is there any way that I can get that URL using C #? I do not trust the vendor to change the URL and obviously it does not have to hardcode.

In the beginning of the XML file ? The Xml-stylesheet looks like this from the element:

   

linux to xml code:

  XDocument xDoc = ...; Var cssUrlQuery = node to xDoc.Nodes () where node.NodeType == XmlNodeType.ProcessingInstruction Select Regex.Match (((Expression Instruction) node. Data, "href = \" (? & Lt; url & gt; .groups ["uRL"] value.  

or linq for the object

  var cssUrls = (XmlNode childNode In doc.ChildNodes where childNode.NodeType == XmlNodeType.ProcessingInstruction & amp; ChildNode .Name == Select "XML-Stylesheet" (XML ProcessSigning Instructions) in ChinaNode, Rexax in Proconode. (Coknode.Data, "href = \" (? & Lt; url & gt; *?) \ ""). Groups ["U RL "] .Value) .toList ();  

xDoc.XPathSelectElement () will not work because XElement can not be entered into XProcessingInstruction for some resons.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -