【问题标题】:parsing xml attribute value解析xml属性值
【发布时间】:2010-12-28 00:49:37
【问题描述】:

我一直在使用 xmlreader 解析 xml 内容,无法使用 xml 文档,但到目前为止,它可以获取除属性内容之外的所有元素内容。我需要解析以下条目中的链接;

<title>XXXX UUUUUU posted a</title>
<category term="NotePosted" label="Note Posted"/>
 <link rel="alternate" type="html"  href="http://www.dfsddsfdsf.com/profile.php?id=sdfdfsfdsdfddfsfd&amp;v=wall&amp;story_dbid=dssdfasdfdasfdsafafafa"/>
<source>......... <source>

我需要链接属性中的 href 标记,但它总是返回 null。

                 While ureader.Read
                    If ureader.HasAttributes Then
                        fId = ureader.GetAttribute("href")
                        If fId.Contains("?v=wall&amp") Then
                            fIdList.Add(fId)
                            Exit While
                        End If
                        If String.IsNullOrEmpty(fId) Then
                            fId = "NOTHING"
                        End If
                    End If
                End While

【问题讨论】:

    标签: xml vb.net visual-studio-2008


    【解决方案1】:
    ureader.GetAttribute("link")
    

    应该是

    ureader.GetAttribute("href")
    

    【讨论】:

      【解决方案2】:

      终于明白了

      刚刚添加了这个

       If ureader.MoveToAttribute("href") Then
                              fId = ureader.ReadInnerXml
       End If
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-27
        相关资源
        最近更新 更多