本文整理汇总了C#中XPathResult类的典型用法代码示例。如果您正苦于以下问题:C# XPathResult类的具体用法?C# XPathResult怎么用?C# XPathResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XPathResult类属于命名空间,在下文中一共展示了XPathResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UsingPositionFunctionTest62
public static void UsingPositionFunctionTest62()
{
var xml = "books.xml";
var startingNodePath = "/bookstore";
var testExpression = @"descendant::node()[position()=7 or position()=2]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
HasAttributes = true,
LocalName = "book",
Name = "book",
HasNameTable = true,
Value =
"\n\t\tSeven Years in Trenton\n\t\t\n\t\t\tJoe\n\t\t\tBob\n\t\t\tTrenton Literary Review Honorable Mention\n\t\t\tUSA\n\t\t\n\t\t12\n\t"
},
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "author",
Name = "author",
HasNameTable = true,
Value = "\n\t\t\tJoe\n\t\t\tBob\n\t\t\tTrenton Literary Review Honorable Mention\n\t\t\tUSA\n\t\t"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例2: Copy
internal XPathResult Copy()
{
XPathResult result = new XPathResult {
resultType = this.resultType
};
switch (this.resultType)
{
case XPathResultType.Number:
result.numberResult = this.numberResult;
return result;
case XPathResultType.String:
result.stringResult = this.stringResult;
return result;
case XPathResultType.Boolean:
result.boolResult = this.boolResult;
return result;
case XPathResultType.NodeSet:
result.nodeSetResult = this.nodeSetResult.Clone();
return result;
}
throw Fx.AssertAndThrow("Unexpected result type.");
}
示例3: AbbreviatedSyntaxTest125
public static void AbbreviatedSyntaxTest125()
{
TestInitialize();
var xml = "XQL_Orders_j1.xml";
var testExpression = @"OrderIDs/CustomerIDs/EmployeeIDs/OrderDates/OrderDate[.='11/16/94']";
var expected = new XPathResult(0);
Utils.XPathNodesetTest(xml, testExpression, expected);
}
示例4: AxesTest11
public static void AxesTest11()
{
var xml = "xp001.xml";
var startingNodePath = "/Doc/Chap/Para/Para/Origin";
var testExpression = @"ancestor::*";
var namespaceManager = new XmlNamespaceManager(new NameTable());
namespaceManager.AddNamespace("book", "http://book.htm");
namespaceManager.AddNamespace("movie", "http://movie.htm");
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Doc",
Name = "Doc",
HasNameTable = true,
Value =
"\n XPath test\n This shall test XPath test\n \n XPath test\n First paragraph Nested Paragraph End of first paragraph \n Second paragraph \n \n \n XPath test\n Direct content\n \n"
},
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Chap",
Name = "Chap",
HasNameTable = true,
Value =
"\n XPath test\n First paragraph Nested Paragraph End of first paragraph \n Second paragraph \n "
},
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Para",
Name = "Para",
HasNameTable = true,
Value = "First paragraph Nested Paragraph End of first paragraph "
},
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Para",
Name = "Para",
HasNameTable = true,
Value = " Nested Paragraph "
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, namespaceManager: namespaceManager,
startingNodePath: startingNodePath);
}
示例5: NodeTestsTest82
public static void NodeTestsTest82()
{
var xml = "xp003.xml";
var startingNodePath = "/Doc";
var testExpression = @"descendant::comment()";
var expected = new XPathResult(0,
new XPathResultToken { NodeType = XPathNodeType.Comment, HasNameTable = true, Value = " Doc Comment " },
new XPathResultToken { NodeType = XPathNodeType.Comment, HasNameTable = true, Value = " Chap Comment " });
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例6: ComplexExpressionsTest31
public static void ComplexExpressionsTest31()
{
var xml = "books.xml";
var startingNodePath = "/bookstore/book[1]";
var testExpression = @"child::author/ancestor::book/attribute::style[.='autobiography']";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Attribute,
LocalName = "style",
Name = "style",
HasNameTable = true,
Value = "autobiography"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例7: NodeSetFunctionsTest223
public static void NodeSetFunctionsTest223()
{
var xml = "xp005.xml";
var startingNodePath = "Doc/Test1";
var testExpression = @"attribute::*[last()]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Attribute,
LocalName = "Attr5",
Name = "Attr5",
HasNameTable = true,
Value = "Last"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例8: MatchesTest234
public static void MatchesTest234()
{
var xml = "xp005.xml";
var startingNodePath = "Doc/Test1";
var testExpression = @"attribute::*[last() - 1]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Attribute,
LocalName = "Attr4",
Name = "Attr4",
HasNameTable = true,
Value = "Fourth"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例9: GlobalizationTest5612
public static void GlobalizationTest5612()
{
TestInitialize();
var xml = "Russian_problem_chars.xml";
var testExpression = @"//root[contains(text(), ""?? ¤ ?? ?? © ? ® ??"")]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "root",
Name = "root",
HasNameTable = true,
Value = "\n?? ¤ ?? ?? © ? ® ?? \n"
});
Utils.XPathNodesetTest(xml, testExpression, expected);
}
示例10: BasicsTest162
public static void BasicsTest162()
{
var xml = "xp001.xml";
var startingNodePath = "/Doc";
var testExpression = @"child::*[(2 * (2 - (3 div (1 + 2))))]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Summary",
Name = "Summary",
HasNameTable = true,
Value = "This shall test XPath test"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例11: BasicsTest161
public static void BasicsTest161()
{
var xml = "xp001.xml";
var startingNodePath = "/Doc";
var testExpression = @"child::*[((((1 + 2) * 3) - 7) div 2)]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Title",
Name = "Title",
HasNameTable = true,
Value = "XPath test"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例12: NodeSetFunctionsTest222
public static void NodeSetFunctionsTest222()
{
var xml = "xp005.xml";
var startingNodePath = "Doc/Test1";
var testExpression = @"child::*[last() - 1]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Child4",
Name = "Child4",
HasNameTable = true,
Value = "Fourth"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例13: CustomerScenariosTest302
public static void CustomerScenariosTest302()
{
var xml = "xpC001.xml";
var startingNodePath = "/Book";
var testExpression = @"/Book/Chapter[last()]/Section[1]/Line[last()]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Line",
Name = "Line",
HasNameTable = true,
Value = "Porsche 911"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例14: PredicatesTest102
public static void PredicatesTest102()
{
var xml = "xp001.xml";
var startingNodePath = "/Doc/Chap/Para/Para/Origin";
var testExpression = @"ancestor::*[3]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
LocalName = "Chap",
Name = "Chap",
HasNameTable = true,
Value =
"\n XPath test\n First paragraph Nested Paragraph End of first paragraph \n Second paragraph \n "
});
;
Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath);
}
示例15: LexicalStructureTest521
public static void LexicalStructureTest521()
{
var xml = "books.xml";
var testExpression = @"/*[node ()]";
var expected = new XPathResult(0,
new XPathResultToken
{
NodeType = XPathNodeType.Element,
HasChildren = true,
HasAttributes = true,
LocalName = "bookstore",
Name = "bookstore",
HasNameTable = true,
Value =
"\n\t\n\t\tSeven Years in Trenton\n\t\t\n\t\t\tJoe\n\t\t\tBob\n\t\t\tTrenton Literary Review Honorable Mention\n\t\t\tUSA\n\t\t\n\t\t12\n\t\n\t\n\t\tHistory of Trenton\n\t\t\n\t\t\tMary\n\t\t\tBob\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tJoeBob\n\t\t\t\tLoser\n\t\t\t\tUS\n\t\t\t\n\t\t\n\t\t55\n\t\n\t\n\t\tXQL The Golden Years\n\t\t\n\t\t\tMike\n\t\t\tHyman\n\t\t\t\n\t\t\t\tXQL For Dummies\n\t\t\t\tJonathan\n\t\t\t\tMarsh\n\t\t\t\n\t\t\n\t\t55.95\n\t\n\t\n\t\tRoad and Track\n\t\t3.50\n\t\t\n\t\tYes\n\t\n\t\n\t\tPC Week\n\t\tfree\n\t\tZiff Davis\n\t\n\t\n\t\tPC Magazine\n\t\t3.95\n\t\tZiff Davis\n\t\t\n\t\t\tCreate a dream PC\n\t\t\t\tCreate a list of needed hardware\n\t\t\t\n\t\t\tThe future of the web\n\t\t\t\tCan Netscape stay alive with Microsoft eating up its browser share?\n\t\t\t\tMSFT 99.30\n\t\t\t\t1998-06-23\n\t\t\t\n\t\t\tVisual Basic 5.0 - Will it stand the test of time?\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\tSport Cars - Can you really dream?\n\t\t\t\n\t\t\n\t\n\t\n\t\tPC Magazine Best Product of 1997\n\t\n\t\n\t\tHistory of Trenton 2\n\t\t\n\t\t\tMary F\n\t\t\tRobinson\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tMary F\n\t\t\t\tRobinson\n\t\t\t\n\t\t\n\t\t55\n\t\n\t\n\t\tHistory of Trenton Vol 3\n\t\t\n\t\t\tMary F\n\t\t\tRobinson\n\t\t\tFrank\n\t\t\tAnderson\n\t\t\tPulizer\n\t\t\t\n\t\t\t\tSelected Short Stories of\n\t\t\t\tMary F\n\t\t\t\tRobinson\n\t\t\t\n\t\t\n\t\t10\n\t\n\t\n\t\tHow To Fix Computers\n\t\t\n\t\t\tHack\n\t\t\ter\n\t\t\tPh.D.\n\t\t\n\t\t08\n\t\n\t\n\t\tTracking Trenton\n\t\t2.50\n\t\t\n\t\n\t\n\t\tTracking Trenton Stocks\n\t\t0.98\n\t\t\n\t\n\t\n\t\tTrenton Today, Trenton Tomorrow\n\t\t\n\t\t\tToni\n\t\t\tBob\n\t\t\tB.A.\n\t\t\tPh.D.\n\t\t\tPulizer\n\t\t\tStill in Trenton\n\t\t\tTrenton Forever\n\t\t\n\t\t6.50\n\t\t\n\t\t\tIt was a dark and stormy night.\n\t\t\tBut then all nights in Trenton seem dark and\n\t\t\tstormy to someone who has gone through what\n\t\t\tI have.\n\t\t\t\n\t\t\t\n\t\t\t\tTrenton\n\t\t\t\tmisery\n\t\t\t\n\t\t\n\t\n\t\n\t\tWho's Who in Trenton\n\t\tRobert Bob\n\t\n\t\n\t\tWhere is Trenton?\n\t\n\t\n\t\tWhere in the world is Trenton?\n\t\n"
});
;
Utils.XPathNodesetTest(xml, testExpression, expected);
}