In XML, what are the nodes with question marks called, and how do I add them in C#?

前端 未结 3 1236
囚心锁ツ
囚心锁ツ 2021-02-19 06:12

Here\'s an example of an XML file created in InfoPath:

  
  

        
相关标签:
3条回答
  • 2021-02-19 06:45

    Those are called processing instructions. You can use the XmlProcessingInstruction class to interact with them in an XmlDocument.

    As with most elements defined within an XmlDocument, you cannot instantiate it directly; you must use the appropriate factory method on XmlDocument (CreateProcessingInstruction in that particular case.)

    0 讨论(0)
  • 2021-02-19 06:51

    These are called processing instructions. Add 'em using XmlDocument.CreateProcessingInstruction.

    0 讨论(0)
  • 2021-02-19 07:00

    Thanks for explaining that these are processing instructions. Using CreateProcessingInstruction as suggested, here is the solution:

      xmlPi = xmldoc.CreateProcessingInstruction("mso-infoPathSolution", "solutionVersion=\"1.0.0.1\" productVersion=\"12.0.0\" PIVersion=\"1.0.0.0\" href=\"file:///C:\\Metastorm\\Sample%20Procedures\\InfoPath%20samples\\Template1.xsn\" name=\"urn:schemas-microsoft-com:office:infopath:Template1:-myXSD-2010-07-21T14-21-13\"");
      xmldoc.AppendChild(xmlPi);
    
    0 讨论(0)
提交回复
热议问题