简体   繁体   中英

XMLReader to read a text

<xhtml:li>
  content1content1content1content1content1content1content1content1
  <xhtml:a href="234455" doc.type="mt">titlex</xhtml:a> 
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  <xhtml:a href="23452345#23556::ah_234555" doc.type="xx">ZZZZZZZZZZZZZZZZ</xhtml:a> 
  </xhtml:li>

Hi,

From the above xml how to extract the text "xxx...". I am able to take content1... and also process other tags but how to get xxxx ?

在为</xhtml:a>结束标记调用ReadEndElement之后,调用ReadString()

It will be of type XmlNodeType.Text. Not knowing your code if you were simply looping through the XmlReader you should get the following node types (ignoring XmlNodeType.Whitespace). You should get the following nodes

  • Element ()
  • Text (content1content..)
  • Element ()
  • Text (titlex)
  • EndElement ()
  • Text (XXXXX....)
  • Element ()
  • Text (ZZZZ...)
  • EndElement ()
  • EndElemnt (/xhtml:li>)

When the NodeType of your reader is of type text you can use the Value property to retrieve the text.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM