c# - 在XML中,带问号的节点叫什么,在C#中如何添加?

标签 c# xml

这是在 InfoPath 中创建的 XML 文件的示例:

  <?xml version="1.0" encoding="UTF-8"?>
  <?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" ?>
  <?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?>
  <my:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-07-21T14:21:13" xml:lang="en-us">
    <my:field1>hello</my:field1>
    <my:field2>world</my:field2>
  </my:myFields>

带问号的前 3 个节点是什么,我如何在 C# 中创建它们?

到目前为止我有这个:

  XmlDocument xmldoc;
  XmlDeclaration xmlDeclaration;

  xmldoc=new XmlDocument();
  xmlDeclaration = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "") as XmlDeclaration;
  xmlDeclaration.Encoding = "UTF-8";
  xmldoc.AppendChild(xmlDeclaration);

这对于顶部的 XML 声明节点工作正常,但我如何创建接下来的两个节点?

提前致谢:)

最佳答案

这些被称为处理指令。使用 XmlDocument.CreateProcessingInstruction 添加它们.

关于c# - 在XML中,带问号的节点叫什么,在C#中如何添加?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3335067/

相关文章:

c# - 一次显示 DataAnnotation 和 IValidatableObject 的所有验证错误

c# - XmlTextWriter 和 XmlWriter 有什么区别?

python - 如何使用python获取父节点下子节点的索引?

c# - Console.WriteLine() 在发布期间写入什么?

c# - XmlSerializer 和工厂创建的元素

python - 查找包含字符串的元素的xpath

android - XMLPullParser 不读取像 <hours/> 这样的空标签

java - Android 布局上的 NullPointer?

c# - 让眼球注视/跟随光标移动 (C#)

C# 事件 : not firing after second level