A
A
Anton_repr2019-12-23 17:58:17
C++ / C#
Anton_repr, 2019-12-23 17:58:17

How to parse certain elements in an xml document?

I managed to find out the title of the book, but I can't get the series/cycle of books ( sequence name ).
My code:

XmlTextReader xtr = new XmlTextReader(@"C:\Users\Boss\Desktop\idiot.fb2");
            while(xtr.Read())
            {
                if(xtr.NodeType == XmlNodeType.Element && xtr.Name == "book-name")
                {
                    string s1 = xtr.ReadElementString();
                    Console.WriteLine("name = " + s1);
                }

                if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "sequence name")
                {
                    string s2 = xtr.ReadElementString();
                    Console.WriteLine("sequence name = " + s2);
                }

XML looks like this:
<sequence name="Книга на все времена" number="0"/>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2019-12-23
@Anton_repr

Tag sequence, no sequence name. And the name and number should be read as its attributes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question