考虑以下 XML 文件:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Input Control="1234567890">
<Patient>
<AccountID>johnsmith@gmail.com</AccountID>
<Name>
<Title>Mr</Title>
<First>John</First>
<Middle>J</Middle>
<Last>Smith</Last>
</Name>
<Addresses>
<Address Type="Billing">
<Line1>123 Main St</Line1>
<Line2>Unit #1</Line2>
<City>Anytown</City>
<State>MD</State>
<PostalCode>78470</PostalCode>
<Country>USA</Country>
<Zone>TR89</Zone>
<Address Type="Contact">
<Line1>55 Main St</Line1>
<City>Anytown</City>
<State>MD</State>
<PostalCode>78470</PostalCode>
<Country>USA</Country>
<Zone>TR89</Zone>
</Address>
</Addresses>
<Phones>
<Phone Type="Daytime">555-221-2525</Phone>
<Phone Type="Evening">555-355-1010</Phone>
</Phones>
<Selects>
<Select Name="Current">0</Select>
</Selects>
</Patient>
</Input>
我需要将 XML(使用 XPath/XQuery)“分解”到下表中:
Account Nam_Pr Nam_Fst Nam_Lst Adrs1Main Adrs2Main CityMain ...
1 Mr. John Smith 123 Main St Unit #1 Anytown
问题是,我需要使用来自 Address Type="Billing 元素的数据填充 AdrsMain 字段,前提是它存在于文件中。否则,AdrsMain 字段是从 Address Type="Contact" 元素填充的。如何我做到这一点?