How to get text from the node in xml file, that co

2019-09-09 02:57发布

I have a very big xml file. I read it using by xmlReader. I have problem when i reach to next line:

<title>Abasia<nemod>(-astasia) (hysterical)</nemod></title>

How I can read all that content. I have to have next string at the end: "Abasia (-astasia) (hysterical)".

I tried to use ReadElementContentAsString() for all elements, but elements like this has exception, because it has child element.

help, please=)

1条回答
何必那么认真
2楼-- · 2019-09-09 03:33

Could something like this work for you?

XmlNodeList itemNode = xmlDoc.SelectNodes("/");
XmlNode titleNode = itemNode.SelectSingleNode("title");
XmlNode nemodNode = itemNode.SelectSingleNode("nemod");
if((titleNode != null) && (dateNode != null))
    Console.WriteLine(titleNode.InnerText + " " + nemodNode.InnerText);
查看更多
登录 后发表回答