本文整理汇总了C#中System.Xml.XmlNodeType类的典型用法代码示例。如果您正苦于以下问题:C# XmlNodeType类的具体用法?C# XmlNodeType怎么用?C# XmlNodeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlNodeType类属于System.Xml命名空间,在下文中一共展示了XmlNodeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNode
public static XmlNode CreateNode(XmlNodeType type, string name)
{
XmlDocument document = new XmlDocument();
XmlNode node = document.CreateNode(type, name, null);
return node;
}
示例2: LoadXml
public static object LoadXml(string fragment, XmlNodeType xmlNodeType, object target, string filename)
{
XamlParser parser = new XamlParser();
parser._filename = filename;
return parser.Read(fragment, xmlNodeType, target);
}
示例3: AssertNode
void AssertNode (int depth, string localName, XmlNodeType nodeType, string value, string type, XmlDictionaryReader reader, string label)
{
Assert.AreEqual (localName, reader.LocalName, label + ".LocalName");
Assert.AreEqual (nodeType, reader.NodeType, label + ".NodeType");
Assert.AreEqual (value, reader.Value, label + ".Value");
Assert.AreEqual (type, reader.GetAttribute ("type"), label + ".GetAttribute('type')");
}
示例4: AdvanceNode
public void AdvanceNode(XmlNodeType xmlNodeType)
{
AdvanceNode();
if (m_xmlReader.NodeType != xmlNodeType)
throw new Exception("The expected node is " + xmlNodeType);
}
示例5: VerifyOwnerOfGivenType
private static void VerifyOwnerOfGivenType(XmlNodeType nodeType)
{
var xmlDocument = new XmlDocument();
var node = xmlDocument.CreateNode(nodeType, "test", string.Empty);
Assert.Equal(xmlDocument, node.OwnerDocument);
}
示例6: ParserNode
public ParserNode(string name, string value, XmlNodeType nodeType)
{
Name = name;
Value = value;
NodeType = nodeType;
Attributes = new Dictionary<string, string>();
}
示例7: OpenXmlMiscNode
/// <summary>
/// Initializes a new instance of the OpenXmlMiscNode class using the
/// supplied XmlNodeType and outer XML values.
/// </summary>
/// <param name="nodeType">The XmlNodeType value.</param>
/// <param name="outerXml">The outer XML of the element.</param>
public OpenXmlMiscNode(XmlNodeType nodeType, string outerXml)
: this(nodeType)
{
if ( String.IsNullOrEmpty( outerXml ) )
{
throw new ArgumentNullException("outerXml");
}
// check the out XML match the nodeType
using (StringReader stringReader = new StringReader(outerXml))
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Prohibit; // set true explicitly for serucity fix
using (XmlReader xmlReader = XmlConvertingReaderFactory.Create(stringReader, settings))
{
xmlReader.Read();
if (xmlReader.NodeType != nodeType)
{
throw new ArgumentException(ExceptionMessages.InvalidOuterXmlForMiscNode);
}
xmlReader.Close();
}
}
this.RawOuterXml = outerXml;
}
示例8: XmlValidatingReader
public XmlValidatingReader( Stream xmlFragment, XmlNodeType fragType, XmlParserContext context ) {
if (xmlFragment == null) {
throw new ArgumentNullException("xmlFragment");
}
impl = new XmlValidatingReaderImpl(xmlFragment, fragType, context);
impl.OuterReader = this;
}
示例9: AssertNodeValues
private void AssertNodeValues (
XmlReader xmlReader,
XmlNodeType nodeType,
int depth,
bool isEmptyElement,
string name,
string prefix,
string localName,
string namespaceURI,
string value,
int attributeCount)
{
Assert.AreEqual (nodeType, xmlReader.NodeType, "NodeType");
Assert.AreEqual (depth, xmlReader.Depth, "Depth");
Assert.AreEqual (isEmptyElement, xmlReader.IsEmptyElement, "IsEmptyElement");
Assert.AreEqual (name, xmlReader.Name, "name");
Assert.AreEqual (prefix, xmlReader.Prefix, "prefix");
Assert.AreEqual (localName, xmlReader.LocalName, "localName");
Assert.AreEqual (namespaceURI, xmlReader.NamespaceURI, "namespaceURI");
Assert.AreEqual ((value != String.Empty), xmlReader.HasValue, "hasValue");
Assert.AreEqual (value, xmlReader.Value, "Value");
Assert.AreEqual (attributeCount > 0, xmlReader.HasAttributes, "hasAttributes");
Assert.AreEqual (attributeCount, xmlReader.AttributeCount, "attributeCount");
}
示例10: ConsumeUntilFirst
/// <summary>
/// Consumes nodes from the reader until the first ocurance of the XmlNodeType identified within types.
/// </summary>
/// <param name="reader">The reader from which to consume Xml nodes</param>
/// <param name="types">The XmlNodeType types of interest which will halt consumption</param>
public static void ConsumeUntilFirst(this XmlReader reader, XmlNodeType[] types)
{
while (Array.IndexOf(types, reader.NodeType) < 0)
{
reader.Read();
}
}
示例11: IsValidChildType
internal override bool IsValidChildType(XmlNodeType type)
{
switch (type)
{
case XmlNodeType.Element:
case XmlNodeType.Text:
case XmlNodeType.CDATA:
case XmlNodeType.EntityReference:
case XmlNodeType.ProcessingInstruction:
case XmlNodeType.Comment:
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
return true;
case XmlNodeType.XmlDeclaration:
{
XmlNode firstChild = this.FirstChild;
if ((firstChild != null) && (firstChild.NodeType == XmlNodeType.XmlDeclaration))
{
return false;
}
return true;
}
}
return false;
}
示例12: XmlDiffViewCharData
/// <summary>
/// Constructor
/// </summary>
/// <param name="value">innerText for this node</param>
/// <param name="nodeType">type of node</param>
internal XmlDiffViewCharData(
string value,
XmlNodeType nodeType)
: base(nodeType)
{
this.InnerText = value;
}
示例13: Close
public override void Close()
{
this.nav = XmlEmptyNavigator.Singleton;
this.nodeType = XmlNodeType.None;
this.state = State.Closed;
this.depth = 0;
}
示例14: AssertNodeValues
private void AssertNodeValues (
XmlReader xmlReader,
XmlNodeType nodeType,
int depth,
bool isEmptyElement,
string name,
string prefix,
string localName,
string namespaceURI,
string value,
int attributeCount)
{
AssertEquals ("NodeType", nodeType, xmlReader.NodeType);
AssertEquals ("Depth", depth, xmlReader.Depth);
AssertEquals ("IsEmptyElement", isEmptyElement, xmlReader.IsEmptyElement);
AssertEquals ("name", name, xmlReader.Name);
AssertEquals ("prefix", prefix, xmlReader.Prefix);
AssertEquals ("localName", localName, xmlReader.LocalName);
AssertEquals ("namespaceURI", namespaceURI, xmlReader.NamespaceURI);
AssertEquals ("hasValue", (value != String.Empty), xmlReader.HasValue);
AssertEquals ("Value", value, xmlReader.Value);
AssertEquals ("hasAttributes", attributeCount > 0, xmlReader.HasAttributes);
AssertEquals ("attributeCount", attributeCount, xmlReader.AttributeCount);
}
示例15: TwoTextNodeBase
private static void TwoTextNodeBase(XmlDocument xmlDocument, InsertType insertType, XmlNodeType nodeType)
{
XmlNode parent = xmlDocument.DocumentElement;
XmlNode refChild = (insertType == InsertType.Prepend) ? parent.FirstChild : parent.LastChild;
XmlNode newChild = TestHelper.CreateNode(xmlDocument, nodeType);
string original = parent.InnerXml;
string expected = (insertType == InsertType.Prepend) ? (newChild.OuterXml + parent.InnerXml)
: ((insertType == InsertType.Append) ? (parent.InnerXml + newChild.OuterXml)
: (refChild.PreviousSibling.OuterXml + newChild.OuterXml + refChild.OuterXml));
// insert new child
var insertDelegate = TestHelper.CreateInsertBeforeOrAfter(insertType);
insertDelegate(parent, newChild, refChild);
// verify
Assert.Equal(3, parent.ChildNodes.Count);
Assert.Equal(expected, parent.InnerXml);
TestHelper.Verify(parent, refChild, newChild);
TestHelper.VerifySiblings(refChild, newChild, insertType);
if (insertType == InsertType.Prepend || insertType == InsertType.Append)
TestHelper.Verify(refChild, newChild, insertType);
// delete new child
parent.RemoveChild(newChild);
Assert.Equal(2, parent.ChildNodes.Count);
TestHelper.VerifySiblings(parent.FirstChild, parent.LastChild, InsertType.Append);
Assert.Equal(original, parent.InnerXml);
}