2014-10-29 36 views
0

我一直在嘗試將每個xml節點轉換爲Excel行以包含所有數據,包括具有子節點的節點。我已經下載了XML編輯器,並嘗試將子節點移出父節點,但是它並不針對整個XML。我也嘗試創建並添加一個XSD,但它清除了我所有的XML內容。如何將每個XML節點轉換爲Excel行

任何幫助將不勝感激,因爲我已經到了死衚衕!這是我試圖轉換爲Excel的XML。我已經刪除了大部分game_action節點,並留下了一些例子。所以,當我這個XML加載到Excel,我可以和我做的Starting_player名,match_player_guid和號碼不放在同一行中的video_time,video_time_start等等等等

<game_actions> 
<game_action> 
    <video_time>159.113</video_time> 
    <video_time_start>149.113</video_time_start> 
    <video_time_end>169.113</video_time_end> 
    <game_time>159.113</game_time> 
    <color>0x0000ff</color> 
    <starting_player> 
    <name>G. Aburjania</name> 
    <match_player_guid>ACA150E6-2DA9-CB29-7963-52D514A5B265</match_player_guid> 
    <number>8</number> 
    </starting_player> 
    <ending_player> 
    <name>C. Maraggos</name> 
    <match_player_guid>532EDB0E-809A-64FD-EAD5-52D514A5C43D</match_player_guid> 
    <number>6</number> 
    </ending_player> 
    <starting_position> 
    <x>496</x> 
    <y>560</y> 
    <zone>6</zone> 
    </starting_position> 
    <ending_position> 
    <x>415</x> 
    <y>567</y> 
    <zone>6</zone> 
    </ending_position> 
    <team> 
    <name>Anorthosis FC</name> 
    <team_guid>bcd1ae4c-4c2d-4c92-978d-6883595d487d</team_guid> 
    </team> 
    <action> 
    <action_id>83</action_id> 
    <name>Pass</name> 
    </action> 
    <direction>right</direction> 
    <comments/> 
    <uid>39EA2490-FB83-3750-5B65-55D0F5372DE7</uid> 
</game_action> 
<game_action> 
    <video_time>165.866</video_time> 
    <video_time_start>155.866</video_time_start> 
    <video_time_end>175.866</video_time_end> 
    <game_time>165.866</game_time> 
    <color>0xcc0000</color> 
    <starting_player> 
    <name>C. Maraggos</name> 
    <match_player_guid>532EDB0E-809A-64FD-EAD5-52D514A5C43D</match_player_guid> 
    <number>6</number> 
    </starting_player> 
    <starting_position> 
    <x>402</x> 
    <y>585</y> 
    <zone>6</zone> 
    </starting_position> 
    <ending_position> 
    <x>675</x> 
    <y>44</y> 
    <zone>6</zone> 
    </ending_position> 
    <team> 
    <name>Anorthosis FC</name> 
    <team_guid>bcd1ae4c-4c2d-4c92-978d-6883595d487d</team_guid> 
    </team> 
    <action> 
    <action_id>88</action_id> 
    <name>Attack</name> 
    </action> 
    <action> 
    <action_id>103</action_id> 
    <name>Wrong Pass</name> 
    </action> 
    <direction>right</direction> 
    <comments/> 
    <uid>C7320CA0-BD4E-2D1B-C4A9-55D14E959346</uid> 
</game_action> </game_actions> 

回答

0

我可以建議3個選項

  1. 從XML數據導入 - 數據功能區中的按鈕。

  2. 嘗試在VBA中使用MSXML2.DOMDocument對象。

  3. 嘗試使用正則表達式(我總是喜歡)例如"<game_action>((?:.|\n)*?)</game_action>"讓你獲得所有game_action標籤。然後遞歸地從裏面獲取其他標籤。我用UDF函數here做了一個加載項。 U可以用它來獲取像這樣的標籤內容=GetRegex(CELL_WITH_XML,"<video_time>((?:.|\n)*?)</video_time>";0)最後一個參數可以改變以獲得下一個標籤