Check if an element exists when parsing XML

后端 未结 4 1969
南旧
南旧 2020-12-15 16:17

I\'m parsing XML. I normally parse it the way I show in the code below which is straightforward The problem is that I don\'t own the XML I\'m parsing and I can\'t change it.

4条回答
  •  孤街浪徒
    2020-12-15 16:50

    You may use the code below:

    string content = item.Element("Content") == null ? "" : item.Element("Content").Value;

提交回复
热议问题