【问题标题】:How to grab the value of an xml node - onix file如何获取一个xml节点的值——onix文件
【发布时间】:2014-05-02 15:34:36
【问题描述】:

我试图在 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

【问题讨论】:

    标签: xml vb.net xmlnode onix


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 2018-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多