0

我试图在 vb 中获取 Text 的值,只有当 TextTypeCode = "02" - 如果我应该将 tes 更改为

 tes = (product.Elements(HandleTagName("OtherText"))).value

它获取包括 TextTypeCode、TextFormat 和 Text PublicationDate 在内的全部信息,但是,当

  tes = (product.Elements(HandleTagName("Text"))).value

它什么也没抓住!

 For Each ThisOtherText In product.Elements(HandleTagName("OtherText"))
     If ThisOtherText.Element(HandleTagName("TextTypeCode")) = "02" Then
     Dim tes as string = (product.Elements(HandleTagName("Text"))).value
     ThisBook.shortDescription = tes
 Next

<Product>
  <OtherText>
    <TextTypeCode>02</TextTypeCode>
    <TextFormat>05</TextFormat>
    <Text>In a series of humorous incidents and hair-raising episodes </Text>
    <TextPublicationDate>20140422</TextPublicationDate>
  </OtherText>
 </Product>

我还将数据库上的 shortDescription 声明为 LONGTEXT

4

1 回答 1

0

名为 Text 的节点不是 Product 的直接子节点,要获取 Text,您必须使用 Product.OtherText.Text,您从第一个查询中获取所有值的原因是 Product.OtherText 获取了包括 Text 节点在内的所有子节点

于 2014-10-02T20:48:34.843 回答