Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP.NET
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>
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??
Posted 21 Sep '12 - 22:55


1 solution

you need to use foreach or for iterate like this
 
 XmlNodeList itemssubject = docsubject.SelectNodes("ISBNdb/BookList/BookData/Subjects");
        for (int i = 0; i < itemssubject.Count; i++)
        {
            XmlNode node = itemssubject[i];
        }
 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 253
1 Rohan Leuva 220
2 Sergey Alexandrovich Kryukov 172
3 Abhinav S 168
4 Mahesh Bailwal 165
0 Sergey Alexandrovich Kryukov 8,528
1 OriginalGriff 6,819
2 CPallini 3,603
3 Rohan Leuva 2,923
4 Maciej Los 2,268


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid