本文介绍了访问xml文件上的第二个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
我想访问以下xml文件中的第二个主题,
我该怎么办?
hi dears,
i want access to second Subject on below xml file,
how i can??
<ISBNdb server_time="2012-09-22T07:22:04Z">
<BookList total_results="1" page_size="10" page_number="1" shown_results="1">
<BookData book_id="thief_of_time" isbn="0061031321" isbn13="9780061031328">
<Title>Thief of time</Title>
<TitleLong>Thief of time: a novel of Discworld</TitleLong>
<AuthorsText>Terry Pratchett</AuthorsText>
<PublisherText publisher_id="harpertorch">New York, N.Y. : HarperTorch, [2002], c2001.</PublisherText>
<Subjects>
<Subject subject_id="discworld_imaginary_place_fiction">Discworld (Imaginary place) -- Fiction</Subject>
<Subject subject_id="fantasy_fiction_aaaa0">Fantasy fiction</Subject>
</Subjects>
</BookData>
</BookList>
</ISBNdb>
我的ASP代码是:
my asp code is:
txtsuject.Replace("-", "");
XmlDocument docsubject = new XmlDocument();
docsubject.LoadXml(txtsuject);
XmlNodeList itemssubject = docsubject.SelectNodes("ISBNdb/BookList/BookData/Subjects");
XmlNode Subject = itemssubject.Item(0).SelectSingleNode("Subject");
我的问题是我如何可以访问第二个主题?
my problem is how i can access to second subject??
推荐答案
XmlNodeList itemssubject = docsubject.SelectNodes("ISBNdb/BookList/BookData/Subjects");
for (int i = 0; i < itemssubject.Count; i++)
{
XmlNode node = itemssubject[i];
}
这篇关于访问xml文件上的第二个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!