-1
:更新時間:導入複雜的XML到Excel 2016
我試圖導入從在線源XML文件到Excel 2016,其工作正常,但響應被限制爲200條記錄,我想創建一個表,並用多個請求填充數據。我工作的響應數據示例如下: -
<?xml version="1.0" encoding="UTF-8"?>
<response uri="/crm/private/xml/Products/getRecords">
<result>
<Products>
<row no="1">
<FL val="PRODUCTID">1250447000004184129</FL>
<FL val="Product Code">
<![CDATA[
1321321321321321
]]>
</FL>
</row>
我現在有以下VB代碼(與其他線程的幫助不大),但我在一個小區獲得所有的值一起,我似乎不能將產品代碼記錄分成單獨的行?
Sub XMLfromPPTExample2()
Dim XDoc As MSXML2.DOMDocument60
Dim xProducts As MSXML2.IXMLDOMNode
Dim xrow As MSXML2.IXMLDOMNode
Dim xChild As MSXML2.IXMLDOMNode
Dim wb As Workbook
Dim Col As Integer
Dim Row As Integer
Set XDoc = New MSXML2.DOMDocument60
XDoc.async = False
XDoc.validateOnParse = False
XDoc.Load ("xml")
LoadOption = xlXmlLoadImportToList
Set xProducts = XDoc.DocumentElement
Set xrow =
xProducts.SelectSingleNode("/response/result/Products/row/FL[val='Product
Code']")
Col = 1
Row = 1
For Each xrow In xProducts.ChildNodes
Row = 1
For Each xChild In xrow.ChildNodes
Worksheets("Sheet2").Cells(Col, Row).Value = xChild.Text
Row = Row + 1
Next xChild
Next xrow
End Sub
它看起來像你有一個傑森你xml。傑森的反序列化可能會更好。 – jdweng
@jdweng - 那不是json,它是一個CDATA XML部分。 –
是的,它是我試圖加載在一個列中的xml,但此時我將FL PRODUCTID和單價與導入時創建的默認模式列在同一列中似乎無法識別差異閱讀一些其他職位,這聽起來像一個循環的VBA代碼會做的伎倆。 –