本文整理汇总了C#中System.Xml.XPath.XPathDocument.MoveToFirstChild方法的典型用法代码示例。如果您正苦于以下问题:C# XPathDocument.MoveToFirstChild方法的具体用法?C# XPathDocument.MoveToFirstChild怎么用?C# XPathDocument.MoveToFirstChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathDocument
的用法示例。
在下文中一共展示了XPathDocument.MoveToFirstChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildVerifier
protected BuildVerifier()
{
this.m_UnsupportedAssemblies = new Dictionary<string, HashSet<string>>();
string uri = Path.Combine(Path.Combine(EditorApplication.applicationContentsPath, "Resources"), "BuildVerification.xml");
XPathNavigator navigator = new XPathDocument(uri).CreateNavigator();
navigator.MoveToFirstChild();
XPathNodeIterator iterator = navigator.SelectChildren("assembly", "");
while (iterator.MoveNext())
{
string attribute = iterator.Current.GetAttribute("name", "");
if ((attribute == null) || (attribute.Length < 1))
{
throw new ApplicationException(string.Format("Failed to load {0}, <assembly> name attribute is empty", uri));
}
string key = iterator.Current.GetAttribute("platform", "");
if ((key == null) || (key.Length < 1))
{
key = "*";
}
if (!this.m_UnsupportedAssemblies.ContainsKey(key))
{
this.m_UnsupportedAssemblies.Add(key, new HashSet<string>());
}
this.m_UnsupportedAssemblies[key].Add(attribute);
}
}
示例2: PopulateTree
public override void PopulateTree (Tree tree)
{
XPathNavigator n = new XPathDocument (Path.Combine (basedir, "toc.xml")).CreateNavigator ();
n.MoveToRoot ();
n.MoveToFirstChild ();
PopulateNode (n.SelectChildren ("node", ""), tree.RootNode);
}
示例3: FromXml
internal static CngKey FromXml(string xml)
{
CngKey key;
using (TextReader reader = new StringReader(xml))
{
using (XmlTextReader reader2 = new XmlTextReader(reader))
{
BigInteger integer;
BigInteger integer2;
XPathNavigator navigator = new XPathDocument(reader2).CreateNavigator();
if (!navigator.MoveToFirstChild())
{
throw new ArgumentException(System.SR.GetString("Cryptography_MissingDomainParameters"));
}
CngAlgorithm algorithm = ReadAlgorithm(navigator);
if (!navigator.MoveToNext(XPathNodeType.Element))
{
throw new ArgumentException(System.SR.GetString("Cryptography_MissingPublicKey"));
}
ReadPublicKey(navigator, out integer, out integer2);
key = CngKey.Import(NCryptNative.BuildEccPublicBlob(algorithm.Algorithm, integer, integer2), CngKeyBlobFormat.EccPublicBlob);
}
}
return key;
}
示例4: LinkXmlReader
public LinkXmlReader()
{
foreach (string userBlacklistFile in AssemblyStripper.GetUserBlacklistFiles())
{
XPathNavigator navigator = new XPathDocument(userBlacklistFile).CreateNavigator();
navigator.MoveToFirstChild();
XPathNodeIterator xpathNodeIterator = navigator.SelectChildren("assembly", string.Empty);
while (xpathNodeIterator.MoveNext())
this._assembliesInALinkXmlFile.Add(xpathNodeIterator.Current.GetAttribute("fullname", string.Empty));
}
}
示例5: WriteNodeXPathNavigatorAttribute
public void WriteNodeXPathNavigatorAttribute ()
{
string xml = "<!DOCTYPE root [<!ELEMENT root EMPTY> <!ATTLIST root implicit NMTOKEN 'nam'>]><root attr='val' />";
XPathNavigator nav = new XPathDocument (new StringReader (xml)).CreateNavigator ();
XmlWriterSettings s = new XmlWriterSettings ();
s.OmitXmlDeclaration = true;
StringWriter sw = new StringWriter ();
XmlWriter w = XmlWriter.Create (sw, s);
w.WriteStartElement ("hoge");
nav.MoveToFirstChild ();
nav.MoveToFirstAttribute ();
w.WriteNode (nav, false);
nav.MoveToNextAttribute ();
w.WriteNode (nav, false);
w.Close ();
AssertType.AreEqual ("<hoge />", sw.ToString ());
}
示例6: ValueAs
public void ValueAs ()
{
string xml = "<root>1</root>";
XPathNavigator nav = new XPathDocument (XmlReader.Create (new StringReader (xml))).CreateNavigator ();
nav.MoveToFirstChild ();
nav.MoveToFirstChild ();
Assert.AreEqual ("1", nav.ValueAs (typeof (string), null), "#1");
Assert.AreEqual (1, nav.ValueAs (typeof (int), null), "#2");
}
示例7: SignificantWhitespaceConstruction
public void SignificantWhitespaceConstruction ()
{
string xml = @"<root>
<child xml:space='preserve'> <!-- --> </child>
<child xml:space='preserve'> </child>
</root>";
XPathNavigator nav = new XPathDocument (
new XmlTextReader (xml, XmlNodeType.Document, null),
XmlSpace.Preserve).CreateNavigator ();
nav.MoveToFirstChild ();
nav.MoveToFirstChild ();
Assert.AreEqual (XPathNodeType.Whitespace, nav.NodeType, "#1");
nav.MoveToNext ();
nav.MoveToFirstChild ();
Assert.AreEqual (XPathNodeType.SignificantWhitespace,
nav.NodeType, "#2");
}
示例8: PushInputDocument
public void PushInputDocument (string url)
{
// todo: detect recursion
Uri baseUriObj = (Input.BaseURI == String.Empty) ? null : new Uri (Input.BaseURI);
Uri absUri = res.ResolveUri (baseUriObj, url);
string absUriString = absUri != null ? absUri.ToString () : String.Empty;
using (Stream s = (Stream)res.GetEntity (absUri, null, typeof(Stream)))
{
if (s == null)
throw new XsltCompileException ("Can not access URI " + absUri.ToString (), null, Input);
XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (absUriString, s, nsMgr.NameTable));
vr.ValidationType = ValidationType.None;
XPathNavigator n = new XPathDocument (vr, XmlSpace.Preserve).CreateNavigator ();
vr.Close ();
n.MoveToFirstChild ();
do {
if (n.NodeType == XPathNodeType.Element)
break;
} while (n.MoveToNext ());
PushInputDocument (n);
}
}
示例9: ExposingSubtreeXmlFragment
public void ExposingSubtreeXmlFragment()
{
string xml = @"
<library>
<book genre='novel' ISBN='1-861001-57-5'>
<title>Pride And Prejudice</title>
</book>
<book genre='novel' ISBN='1-81920-21-2'>
<title>Hook</title>
</book>
</library>";
XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();
// <library>
nav.MoveToFirstChild();
// <book>
nav.MoveToFirstChild();
SubtreeeXPathNavigator sub = new SubtreeeXPathNavigator(nav, true);
// Enable fragment reading.
XPathNavigatorReader reader = new XPathNavigatorReader(sub, true);
reader.MoveToContent();
string books = reader.ReadFragmentXml();
sub.MoveToRoot();
reader = new XPathNavigatorReader(sub, true);
reader.MoveToContent();
string books2 = reader.ReadFragmentXml();
Assert.AreEqual(books, books2);
Assert.AreEqual(
"<book genre=\"novel\" ISBN=\"1-861001-57-5\"><title>Pride And Prejudice</title></book><book genre=\"novel\" ISBN=\"1-81920-21-2\"><title>Hook</title></book>",
books);
}
示例10: XPathDocumentFragmentLoading
public void XPathDocumentFragmentLoading()
{
string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";
XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();
// <customer>
nav.MoveToFirstChild();
// <pp:order>
nav.MoveToFirstChild();
// <order>
nav.MoveToNext();
XmlReader reader = new XPathNavigatorReader(nav);
XPathNavigator clone = new XPathDocument(reader).CreateNavigator();
clone.MoveToFirstChild();
Assert.AreEqual("order", clone.LocalName);
Assert.AreEqual("urn-kzu", clone.NamespaceURI);
}
示例11: XPathDocumentLoading
public void XPathDocumentLoading()
{
string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";
XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();
XmlReader reader = new XPathNavigatorReader(nav);
XPathNavigator clone = new XPathDocument(reader).CreateNavigator();
clone.MoveToFirstChild();
Assert.AreEqual("customer", clone.LocalName);
Assert.AreEqual("urn-kzu", clone.NamespaceURI);
clone.MoveToAttribute("id", "urn-pepenamespace");
Assert.AreEqual("aba", clone.Value);
clone.MoveToParent();
clone.MoveToFirstChild();
Assert.AreEqual("pp:order", clone.Name);
Assert.IsTrue(clone.IsEmptyElement);
}
示例12: XmlDocumentFragmentLoading
public void XmlDocumentFragmentLoading()
{
string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";
XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();
// <customer>
nav.MoveToFirstChild();
// <pp:order>
nav.MoveToFirstChild();
// <order>
nav.MoveToNext();
XmlReader reader = new XPathNavigatorReader(nav);
XmlDocument doc = new XmlDocument(nav.NameTable);
doc.Load( reader );
Assert.AreEqual("order", doc.DocumentElement.LocalName);
Assert.AreEqual("urn-kzu", doc.DocumentElement.NamespaceURI);
Assert.AreEqual(1, doc.DocumentElement.Attributes.Count);
}
示例13: GetData
/// <summary>
/// Fills in the data table with data from a list of HealthRecordItem.
/// </summary>
public void GetData(
HealthRecordAccessor record, IList<HealthRecordItem> items, int startIndex, int count)
{
HealthRecordItemDataTableView effectiveView =
this.ApplyEffectiveView(record.Connection);
IDictionary<Guid, HealthRecordItemTypeDefinition> typeDefDict =
ItemTypeManager.GetHealthRecordItemTypeDefinition(_filter.TypeIds,
record.Connection);
HealthRecordItemTypeDefinition sttTypeDef =
typeDefDict.Count == 1 ? typeDefDict[_filter.TypeIds[0]] : null;
bool firstRow = true;
string transformName =
(effectiveView == HealthRecordItemDataTableView.SingleTypeTable) ? "stt" : "mtt";
for (int i = startIndex; i < items.Count && i < count; ++i)
{
HealthRecordItem item = items[i];
XPathNavigator itemTransformNav;
IDictionary<string, XmlDocument> transformedXmlData = item.TransformedXmlData;
if (transformedXmlData.ContainsKey(transformName))
{
itemTransformNav =
transformedXmlData[transformName].CreateNavigator().SelectSingleNode(
"//data-xml/row");
}
else
{
string transform = (sttTypeDef == null) ?
typeDefDict[item.TypeId].TransformItem(transformName, item) :
sttTypeDef.TransformItem(transformName, item);
itemTransformNav = new XPathDocument(XmlReader.Create(new StringReader(
transform))).CreateNavigator();
if (!itemTransformNav.MoveToFirstChild())
{
continue;
}
}
if (firstRow)
{
SetupColumns(itemTransformNav.Clone());
firstRow = false;
}
AddRow(itemTransformNav);
}
}
示例14: DeserializeItem
/// <summary>
/// Deserializes the response XML into a <see cref="HealthRecordItem"/> or derived type
/// based on the registered health record item handler.
/// </summary>
///
/// <param name="thingReader">
/// The XML representation of the item.
/// </param>
///
/// <returns>
/// The <see cref="HealthRecordItem"/> or derived class instance representing the data
/// in the XML.
/// </returns>
///
/// <exception cref="System.Reflection.TargetInvocationException">
/// The constructor of the type being created throws an
/// exception. The inner exception is the exception thrown by the
/// constructor.
/// </exception>
///
/// <exception cref="MissingMethodException">
/// The default constructor of the type being created is not public.
/// If you registered the type handler, be sure that the type you
/// registered for the item type class has a public default
/// constructor.
/// </exception>
///
internal static HealthRecordItem DeserializeItem(XmlReader thingReader)
{
HealthRecordItem result = null;
string thingString = thingReader.ReadOuterXml();
XmlReaderSettings settings = SDKHelper.XmlReaderSettings;
settings.IgnoreWhitespace = false;
XPathNavigator thingNav;
using (XmlReader reader =
XmlReader.Create(new StringReader(thingString), settings))
{
thingNav = new XPathDocument(reader, XmlSpace.Preserve).CreateNavigator();
}
thingNav.MoveToFirstChild();
Guid typeId = GetTypeId(thingNav);
HealthRecordItemTypeHandler handler = null;
if (typeId == _applicationSpecificId)
{
// Handle application specific health item records by checking for handlers
// for the application ID and subtype tag. If the handler doesn't exist
// the default handler will be picked up below.
AppDataKey appDataKey = GetAppDataKey(thingNav);
if (appDataKey != null)
{
if (_appSpecificHandlers.ContainsKey(appDataKey.AppId))
{
if (_appSpecificHandlers[appDataKey.AppId].ContainsKey(appDataKey.SubtypeTag))
{
handler =
_appSpecificHandlers[appDataKey.AppId][appDataKey.SubtypeTag];
}
}
}
}
if (handler == null &&
TypeHandlers.ContainsKey(typeId))
{
handler = TypeHandlers[typeId];
}
if (handler != null)
{
result = (HealthRecordItem)Activator.CreateInstance(handler.ItemTypeClass);
}
else
{
result = new HealthRecordItem(typeId);
}
result.ParseXml(thingNav, thingString);
return result;
}
示例15: SerializeAndReadOutput
private XPathNavigator SerializeAndReadOutput(ContentItem item)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
CreateExporter().Export(item, ExportOptions.Default, sw);
StringReader sr = new StringReader(sb.ToString());
XPathNavigator navigator = new XPathDocument(sr).CreateNavigator();
navigator.MoveToFirstChild();
return navigator;
}