0
我有一個輸出爲XML像這樣的SQL查詢:我該怎麼操作我的XML輸出中使用XSL樣式表
<root>
<ELECTION>
<title1>Carroll County Board Dist. 2</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5188</Winner>
<WinningVotes>1445</WinningVotes>
<WinningParty>D</WinningParty>
<Winner1>Gary Imel</Winner1>
<WinnerSelected>1</WinnerSelected>
<WinnerPercent>27</WinnerPercent>
<Loser>5187</Loser>
<LosingVotes>1382</LosingVotes>
<LosingParty>D</LosingParty>
<Loser2>Ronald Preston</Loser2>
<LoserPercent>26</LoserPercent>
<LoserSelected>0</LoserSelected>
<title1>Carroll County Board Dist. 2</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5189</Winner>
<WinningVotes>1281</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>CherylCole</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5190</Loser>
<LosingVotes>1208</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>AnnetteRahn</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Circuit Clerk</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5192</Winner>
<WinningVotes>12893</WinningVotes>
<WinningParty>R</WinningParty>
<Winner1>Jackie Oberg</Winner1>
<WinnerSelected>1</WinnerSelected>
<WinnerPercent>56</WinnerPercent>
<Loser>5191</Loser>
<LosingVotes>10214</LosingVotes>
<LosingParty>D</LosingParty>
<Loser2>David Guzzardo</Loser2>
<LoserPercent>44</LoserPercent>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5205</Winner>
<WinningVotes>6408</WinningVotes>
<WinningParty>R</WinningParty>
<Winner1>Karen Urick</Winner1>
<WinnerSelected>1</WinnerSelected>
<WinnerPercent>6</WinnerPercent>
<Loser>5204</Loser>
<LosingVotes>6390</LosingVotes>
<LosingParty>R</LosingParty>
<Loser2>Tim Wells</Loser2>
<LoserPercent>6</LoserPercent>
<LoserSelected>1</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5203</Winner>
<WinningVotes>6362</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>KathyNelson</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5212</Loser>
<LosingVotes>6343</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>MarvinGradert</Loser>
<LoserSelected>1</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5206</Winner>
<WinningVotes>6281</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>RickLivesay</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5207</Loser>
<LosingVotes>5618</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>LorenRathjen</Loser>
<LoserSelected>1</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5208</Winner>
<WinningVotes>5548</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>BillPreston</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5210</Loser>
<LosingVotes>5493</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>JacobWaller</Loser>
<LoserSelected>1</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5194</Winner>
<WinningVotes>5479</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>AnnDeSmith</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5193</Loser>
<LosingVotes>5269</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>JoAnneHillman</Loser>
<LoserSelected>1</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5211</Winner>
<WinningVotes>5116</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>CharlesLotridge</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5209</Loser>
<LosingVotes>5103</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>JonZahm</Loser>
<LoserSelected>0</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5195</Winner>
<WinningVotes>5034</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>JosephSwan</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5196</Loser>
<LosingVotes>4674</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>BettyMurphy</Loser>
<LoserSelected>0</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5201</Winner>
<WinningVotes>4639</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>KarenRussell</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5198</Loser>
<LosingVotes>4611</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>DennisSullivan</Loser>
<LoserSelected>0</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5200</Winner>
<WinningVotes>4559</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>JimKing</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5197</Loser>
<LosingVotes>4555</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>IanMalmstrom</Loser>
<LoserSelected>0</LoserSelected>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5199</Winner>
<WinningVotes>4323</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>JimEccher</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5202</Loser>
<LosingVotes>3734</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>JohnSmith</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
</root>
我想獲得每<title1>
通過</LoserSelected>
包裹着<ELECTION>
和</ELECTION>
正確格式化作爲一個XML文檔。其中有些比賽只有2名候選人。有些比賽有19名以上的候選人。不幸的是,我的代理商一次只能顯示2位候選人。所以<title1>
之間</LoserSelected>
之間的所有內容都包含我需要爲2位候選人解析的數據。我打算嘗試msxsl inputfile.xml translation.xsl -o outputfile.xml
從我的期望輸出的一個例子上面會:
<root>
<ELECTION>
<title1>Carroll County Board Dist. 2</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5188</Winner>
<WinningVotes>1445</WinningVotes>
<WinningParty>D</WinningParty>
<Winner1>Gary Imel</Winner1>
<WinnerSelected>1</WinnerSelected>
<WinnerPercent>27</WinnerPercent>
<Loser>5187</Loser>
<LosingVotes>1382</LosingVotes>
<LosingParty>D</LosingParty>
<Loser2>Ronald Preston</Loser2>
<LoserPercent>26</LoserPercent>
<LoserSelected>0</LoserSelected>
</ELECTION>
<title1>Carroll County Board Dist. 2</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5189</Winner>
<WinningVotes>1281</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>CherylCole</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5190</Loser>
<LosingVotes>1208</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>AnnetteRahn</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Circuit Clerk</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5192</Winner>
<WinningVotes>12893</WinningVotes>
<WinningParty>R</WinningParty>
<Winner1>Jackie Oberg</Winner1>
<WinnerSelected>1</WinnerSelected>
<WinnerPercent>56</WinnerPercent>
<Loser>5191</Loser>
<LosingVotes>10214</LosingVotes>
<LosingParty>D</LosingParty>
<Loser2>David Guzzardo</Loser2>
<LoserPercent>44</LoserPercent>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5205</Winner>
<WinningVotes>6408</WinningVotes>
<WinningParty>R</WinningParty>
<Winner1>Karen Urick</Winner1>
<WinnerSelected>1</WinnerSelected>
<WinnerPercent>6</WinnerPercent>
<Loser>5204</Loser>
<LosingVotes>6390</LosingVotes>
<LosingParty>R</LosingParty>
<Loser2>Tim Wells</Loser2>
<LoserPercent>6</LoserPercent>
<LoserSelected>1</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5203</Winner>
<WinningVotes>6362</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>KathyNelson</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5212</Loser>
<LosingVotes>6343</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>MarvinGradert</Loser>
<LoserSelected>1</LoserSelected>
</ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5206</Winner>
<WinningVotes>6281</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>RickLivesay</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5207</Loser>
<LosingVotes>5618</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>LorenRathjen</Loser>
<LoserSelected>1</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5208</Winner>
<WinningVotes>5548</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>BillPreston</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5210</Loser>
<LosingVotes>5493</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>JacobWaller</Loser>
<LoserSelected>1</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5194</Winner>
<WinningVotes>5479</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>AnnDeSmith</Winner>
<WinnerSelected>1</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5193</Loser>
<LosingVotes>5269</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>JoAnneHillman</Loser>
<LoserSelected>1</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5211</Winner>
<WinningVotes>5116</WinningVotes>
<WinningParty>R</WinningParty>
<Winner>CharlesLotridge</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5209</Loser>
<LosingVotes>5103</LosingVotes>
<LosingParty>R</LosingParty>
<Loser>JonZahm</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5195</Winner>
<WinningVotes>5034</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>JosephSwan</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5196</Loser>
<LosingVotes>4674</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>BettyMurphy</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5201</Winner>
<WinningVotes>4639</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>KarenRussell</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5198</Loser>
<LosingVotes>4611</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>DennisSullivan</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5200</Winner>
<WinningVotes>4559</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>JimKing</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5197</Loser>
<LosingVotes>4555</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>IanMalmstrom</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
<ELECTION>
<title1>Henry County Board Dist. 1</title1>
<PrecintPercent>100</PrecintPercent>
<Winner>5199</Winner>
<WinningVotes>4323</WinningVotes>
<WinningParty>D</WinningParty>
<Winner>JimEccher</Winner>
<WinnerSelected>0</WinnerSelected>
<PrecintPercent>100</PrecintPercent>
<Loser>5202</Loser>
<LosingVotes>3734</LosingVotes>
<LosingParty>D</LosingParty>
<Loser>JohnSmith</Loser>
<LoserSelected>0</LoserSelected>
</ELECTION>
</root>
正如你所看到的,亨利縣有很多的候選人,但我只能在同一時間使用寫2名候選人我的自動收報機。如果我有兩個候選人,每個都包含<ELECTION>
和</ELECTION>
標籤,我可以正確解析它。
截至目前,我有這個pathes作爲
FOR XML PATH ('ELECTION'), root('root')
所以它不產生<ELECTION>
和</ELECTION>
了。
任何人都可以幫忙,或提供任何建議,以正確地格式化XML格式嗎?
謝謝你
任何人都可以幫忙嗎?
人,它需要很長一段時間它解析實際的整個文件.. ..但它的工作原理!非常感謝你!!!! – user3242661