本文整理汇总了C#中System.Xml.XmlDocument.GetChildText方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.GetChildText方法的具体用法?C# XmlDocument.GetChildText怎么用?C# XmlDocument.GetChildText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.GetChildText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
/*Problem 5. Simple Search for Books. */
static void Main()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("..\\..\\test6.xml");
string title = xmlDoc.GetChildText("/query/title");
string author = xmlDoc.GetChildText("/query/author");
string isbn = xmlDoc.GetChildText("/query/isbn");
var books = BookstoreDAL.FindBooksByTitleAndAuthorAndISBN(title, author, isbn);
if (books.Count > 0)
{
Console.WriteLine("{0} {1} found:", books.Count, books.Count != 1 ? "books":"book");
foreach (var book in books)
{
Console.WriteLine("{0} --> {1} {2}", book.Key, book.Value == 0 ? "no" : book.Value.ToString(), book.Value != 1 ? "reviews" : "review");
}
}
else
{
Console.WriteLine("Nothing found");
}
}
示例2: Main
public static void Main(string[] args)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("../../simple-query.xml");
string title = xmlDoc.GetChildText("/query/title");
string author = xmlDoc.GetChildText("/query/author");
string isbn = xmlDoc.GetChildText("/query/isbn");
var books = BookstoreDAL.FindBooksByTitleAuthorAndIsbn(title, author, isbn);
if (books.Count > 0)
{
Console.WriteLine("{0} books found:", books.Count);
foreach (var book in books)
{
Console.WriteLine("{0} --> {1} reviews", book.Title, book.Reviews.Count);
}
}
else
{
Console.WriteLine("Nothing found");
}
}
示例3: Main
static void Main()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("../../simple-query.xml");
string authorname = xmlDoc.GetChildText("/query/author");
string title = xmlDoc.GetChildText("/query/title");
string isbn = xmlDoc.GetChildText("/query/isbn");
var books =
BookstoreDAL.FindBookByTitleAuthorOrISBN(authorname, title, isbn);
if (books.Count > 0)
{
foreach (var book in books)
{
Console.WriteLine("{0} books found:");
Console.WriteLine("{0} --> ", book.Title);
}
}
else
{
Console.WriteLine("Nothing found");
}
}
示例4: FindBooks
public static void FindBooks(string filePath)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filePath);
string title = xmlDoc.GetChildText("query/title");
string authorName = xmlDoc.GetChildText("query/author");
string isbn = xmlDoc.GetChildText("query/isbn");
List<Book> books = BookstoreDAL.FindBooksByTitleAuthorIsbn(title, authorName, isbn);
if (books.Count > 0)
{
Console.WriteLine("{0} books found:", books.Count());
foreach (Book book in books)
{
Console.WriteLine(book.Title);
}
}
else
{
Console.WriteLine("Nothing found");
}
}