1
我需要從SQL Server中的XML中提取信息。該文件的格式與下面的格式類似。我無法解析出這種文檔樣式的信息。有誰知道爲什麼要做到這一點?在SQL Server中從XML中提取信息
<ExtractSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ConnectorSettings connectorScriptId="74" channelDomain="Diag" isActive="true">
<StepSettings stepScriptId="9" stepType="Demo" isActive="true" sequence="1" />
<StepSettings stepScriptId="23" stepType="Enc" isActive="true" sequence="2" />
</ConnectorSettings>
<ConnectorSettings connectorScriptId="15" channelDomain="Doc" isActive="true">
<StepSettings stepScriptId="9" stepType="Demo" isActive="true" sequence="1" />
<StepSettings stepScriptId="23" stepType="Enc" isActive="true" sequence="2" />
<StepSettings stepScriptId="61" stepType="Lab" isActive="true" sequence="3" />
</ConnectorSettings>
<ConnectorSettings connectorScriptId="12" channelDomain="Imm" isActive="true">
<StepSettings stepScriptId="9" stepType="Demo" isActive="true" sequence="1" />
<StepSettings stepScriptId="16" stepType="Imm" isActive="true" sequence="2" />
</ConnectorSettings>
<ConnectorSettings connectorScriptId="46" channelDomain="Lab" isActive="true">
<StepSettings stepScriptId="9" stepType="Demo" isActive="true" sequence="1" />
</ConnectorSettings>
</ExtractSettings>
我在SQL Server之前做到了這一點,但格式是這樣的
<ConnectorSetting>
<StepSettings>70<StepSettings/>
<Steptype>Enc<Steptype/>
<StepSettings>23<StepSettings/>
<Steptype>Demo<Steptype/>
</ConnectorSettings>
這使得它更容易處理。
我試了幾件事情,但已大多試圖讓這些工作
select
stuff.connectorSettings.value('stepScriptID', 'varchar(50)')
from
@xml.nodes('ROOT/ConnectorSettings/stepscript') as stuff(connectorSettings);
和
exec sp_xml_preparedocument @idoc output, @xml;
select * from OPENXML(@idoc,'/ROOT/ConnectorSettings',4)
我有點失去了在這一點所以任何的建議是,讚賞。