我想通过从XML_TAGS
表中获取标记以及MAPPED_TAGS_ATTRIBUTES
表中的属性来显示XML文件 - 类似于<element attributes></element>
:
String sql = "SELECT Dtd_Tag,Dtd_Attribute_Name
FROM Xml_Tags,
Mapped_Tags_Attributes
WHERE Mapped_Tags_Attributes.Pdf_Tag = Xml_Tags.Pdf_Tag
ORDER BY Mapped_Tags_Attributes.Pdf_Tag
FOR XML AUTO";
答案 0 :(得分:1)
查询:
select
c.CustomerId as "@Id",
c.AcountNumber as "@AcountNumber"
from Customer c
for xml path('Customer'), root('Customers')
结果:
<Customers>
<Customer Id="1" AccountNumber="X120" />
<Customer Id="2" AccountNumber="X121" />
</Customers>