





















public class ManagementXml
...{
public ManagementXml()
...{
}
/**////
public void AddElement()
...{
System.Xml.XmlNode newElement;
newElement = xml.CreateElement("Keyword");
newElement.InnerText = "Value";
xml.AppendChild(newElement);
}
/**////
public void EnumAttribute()
...{
foreach (System.Xml.XmlAttribute attribute in node.Attributes)
...{
}
}
/**////
public void Find_A_Node()
...{
System.Xml.XmlNodeList nodes;
nodes = xml.GetElementsByTagName("ElementName");
}
/**////
public void Infer_A_Schema_From_A_Xml()
...{
// Gets the schema.
System.Xml.Schema.XmlSchemaInference infer = new System.Xml.Schema.XmlSchemaInference();
System.Xml.Schema.XmlSchemaSet sc = new System.Xml.Schema.XmlSchemaSet();
sc = infer.InferSchema(new System.Xml.XmlTextReader("sample.xml"));
// Writes the schema.
System.Xml.XmlWriter w = System.Xml.XmlWriter.Create(new System.IO.StreamWriter("sampleSchema.xsd"));
foreach (System.Xml.Schema.XmlSchema schema in sc.Schemas())
...{
schema.Write(w);
}
// Update the schema with another xml fragment.
sc = infer.InferSchema(System.Xml.XmlReader.Create("anothersample.xml"), sc);
w = System.Xml.XmlWriter.Create(new System.IO.StreamWriter("anotherschema.xsd"));
foreach (System.Xml.Schema.XmlSchema schema in sc.Schemas())
...{
schema.Write(w);
}
}
/**////
public void Iterate_Named_Nodes()
...{
foreach (System.Xml.XmlNode node in xmlDoc.GetElementsByTagName("ElementName"))
...{
}
}
/**////
public void NavigateData_with_XPathNavigator()
...{
System.Xml.XPath.XPathNavigator nav = xmlDoc.CreateNavigator();
// Move to the first non-comment element.
nav.MoveToChild(System.Xml.XPath.XPathNodeType.Element);
System.Xml.XPath.XPathNodeIterator nodeIterator = nav.SelectChildren(System.Xml.XPath.XPathNodeType.Element);
while (nodeIterator.MoveNext())
...{
}
}
/**////
public void Read_ClassData_From_Xml()
...{
System.Xml.XmlSerializer reader = new System.Xml.XmlSerializer(typeof(TheClass));
using (System.IO.StreamReader file = new System.IO.StreamReader(@"ClassData.xml"))
...{
TheClass fileData;
fileData = (TheClass)reader.Deserialize(file);
}
}
/**////
public void Read_Data_With_XmlTextReader()
...{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("Snippet.xml");
string contents = reader.ReadInnerXml();
}
/**////
public void Read_Xml_Form_String()
...{
// Create the reader.
System.Xml.XmlReader reader = System.Xml.XmlReader.Create(new System.IO.StringReader("
while (reader.Read())
...{
}
}
/**////
while (reader.Read())
...{
}
}
/**////
// Transform the file.
processor.Transform("data.xml", null, stream);
}
}
/**////
xslt.Load("theXsltFile.xslt");
xslt.Transform("theXmlFile.xml", "theOutputFile.html");
}
/**////
using (System.IO.StreamWriter file = new System.IO.StreamWriter("SerializedData.xml"))
...{
writer.Serialize(file, dataToWrite);
}
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。