感谢您提出的建议 search dataset from xml file 使用Xpath而不是我以前的帖子中的数据集。我已经使用xpath成功过滤了我的xml数据(参见上一篇文章),但现在我需要在表格中显示数据。我该怎么做呢?我需要显示某些值。如何选择我想要的节点并显示它们?
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>"
答案 0 :(得分:0)
使用XSLT将XML转换为任何其他XML(包括HTML)。