In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the XML processing instruction for C # operation". In the daily operation, I believe that many people have doubts about what the XML processing instruction for C# operation is. The editor consulted all kinds of data and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the doubt of "what is the XML processing instruction for C# operation?" Next, please follow the editor to study!
What are processing instructions?
A processing instruction (Processing Instructions,PI) is a tag surrounded by a "" to describe specific application information. XML documents can contain multiple processing instructions for different applications. The processing instruction consists of two parts, target and value. The role of target is similar to "name", and the string immediately after target is that value,value can contain multiple tags.
So is the Xml declaration a processing instruction? The answer is yes, the XML declaration is a special processing instruction, which is special because its value format is predefined. Another common example of processing instructions is external stylesheets. The stylesheet processing instruction also has a predefined value value, which consists of pseudo attributes. Why it is called a "pseudo attribute" is because its value looks like several normal XML attributes, but in fact they are just a string.
However, the format of the value value of the processing instruction is open. The processing instruction is not part of the document data, and the XML parser ignores its contents and passes it directly to the client application.
InfoPath in Microsoft's Office suite uses processing instructions to indicate whether Xml files can be viewed by InfoPath clients.
Another processing instruction, mso-infoPathSolution, tells InfoPath the location of the solution template. The template contains the layout transformation information of the layout Xml file, the schema information of the view and the data source information.
So how do you manipulate Xml documents that contain processing instructions in a C # application?
How do we process and read the processing instructions that already exist in the XML document? First, processing instructions can be selected like other nodes in the document. XPath uses the predicate (predicate) processing-instruction () to test whether the node is a processing instruction.
In the System.XML namespace, there is a XmlProcessingInstruction class. When you select a node from the Xml document, you can convert the returned XMLNode object to this type, which provides a very friendly interface to manipulate the value of processing instructions. To read its value, you only need to access the object's Value property.
To change the value of the processing instruction, you only need to assign the new value to the object's Value property.
To add a new processing instruction to the XML document, you can use the CreateProcessingInstruction method of the XMLDocument class. Then use the InsertBefore or InsertAfter methods to add the XmlProcessingInstruction object to the XML document.
To remove an existing processing instruction from an XML document, first select the XmlNode object of the processing instruction, but you do not need to convert it to a XMLProcessingInstruction object. It can then be deleted using the RemoveChild method of the XMLDocument class.
The following code contains all of the C# operations mentioned in this article:
/ / Xml file path string strPath = "path" / / load Xml document content XmlDocument doc = new XmlDocument (); doc.XmlResolver = null; doc.Load (strPath); / / display Xml document content Console.WriteLine (doc.InnerXml.ToString (). Replace (">\ r\ n\ n\ r\ n\ n
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.