开发者

How can i display XML data in a HTML table

开发者 https://www.devze.com 2022-12-21 11:51 出处:网络
Th开发者_JAVA百科anks for suggestion given in search dataset from xml file to use Xpath instead of dataset as in my previous post. I\'ve successfully filtered my xml data (see previous post) using xp

Th开发者_JAVA百科anks for suggestion given in search dataset from xml file to use Xpath instead of dataset as in my previous post. I've successfully filtered my xml data (see previous post) using xpath but now I need to display data in a table. How do I do this? I would need to display certain values. How can I choose the nodes I want and display them?

    Dim xdoc As New XPathDocument(xt)
    Dim nav As XPathNavigator = xdoc.CreateNavigator()

    Dim expr As XPathExpression = nav.Compile("pf:CONTRACTS/pf:CONTRACT[contains(pf:KEYWORDS,'" word "')]")

    Dim tr As String = Nothing
    Dim namespaceManager As XmlNamespaceManager = New XmlNamespaceManager(nav.NameTable)
    namespaceManager.AddNamespace("pf", "http://namespace.co.uk/")
    expr.SetContext(namespaceManager)
    Dim nodes As XPathNodeIterator = nav.Select(expr)

      While nodes.MoveNext()
     'I would need to have "Contact ID", "Contract Name", etc.        
        tr += "<tr><td>" & nodes.Current.Value & "</td><td></td><td></td><td></td></tr>"
    End While
            Dim th As String = "<th>Commodity</th><th>Name</th><th>Supplier</th><th>Name</th>"
    div1.InnerHtml = ("<table class='datatable1'>" & th) + tr & "</table>"


Use XSLT to transform XML to any other XML (including HTML).

0

精彩评论

暂无评论...
验证码 换一张
取 消