不添加数据集的XML输出 [英] XML output without adding dataset
问题描述
美好的一天,
我正在尝试创建xml并将其导出到本地磁盘,但是这样做时,它会继续重新格式化并添加诸如数据集/表之类的值.我希望xml保持与在SQL中运行时所得到的形状/格式相同的形状/格式.这是我的xml查询:
I'm trying to create xml and export it to the local disk but when doing that it keeps reformatting it and adding values like datasets/tables. I would like for xml to retain same shape/format as what I get when running it in SQL. Here is my xml query:
With XMLNAMESPACES ('http://www.courts.mo.gov/exchanges/MoEcfExchangeExtensions/1.0' as "mo-ecf-ext",
'http://niem.gov/niem/domains/jxdm/4.1' as "j", 'http://niem.gov/niem/structures/2.0' as "s", 'http://niem.gov/niem/niem-core/2.0' as "nc",
'http://www.courts.mo.gov/exchanges/MoEcfExchange/1.0' as "mo-ecf")
SELECT
'p1' as 'nc:Person/@s:id',
tblSuits.FirstName as 'nc:Person/nc:PersonName/nc:PersonGivenName',
tblSuits.MiddleName as 'nc:Person/nc:PersonName/nc:PersonMiddleName', ***hidden***
tblSuits.PDFb64 as 'mo-ecf-ext:PrimaryDocument/nc:DocumentBinary/nc:BinaryBase64Object',
'application/pdf' as 'mo-ecf-ext:PrimaryDocument/nc:DocumentBinary/nc:BinaryFormatID',
'PETITION' as 'mo-ecf-ext:PrimaryDocument/nc:DocumentTitleText',
'APTCC' as 'mo-ecf-ext:PrimaryDocument/mo-ecf-ext:DocumentCategoryText',
'pd1' as 'mo-ecf-ext:EntityDocumentAssociation/nc:DocumentReference/@s:ref',
'o1' as 'mo-ecf-ext:EntityDocumentAssociation/mo-ecf:EntityOrganizationReference/@s:ref'
FROM tblSuits
Where SuitID = 10
FOR XML PATH ('mo-ecf:MoEcfExchange');
如果我将其复制并粘贴到空的xml文件中,则此查询会以正确的格式创建xml文件,以便我们发送给其他代理商.我也可以将其以正确的格式插入到xml字段中的xml字段中,但是当我尝试将其导出到vb.net中的文件时,会得到其他提示 数据集和格式都消失了.
This query creates xml file in proper format for us to send to another agency if I copy and past it into empty xml file. I can also insert this into xml field in my xml field in proper format but when I try to export it to a file in vb.net I get additional dataset and formatting is all gone.
'starting to test generation of xml file
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
connetionString = "Data Source=servername;Initial Catalog=database;Trusted_Connection=True;"
connection = New SqlConnection(connetionString)
sql = "select xmltest from tblSuits where SuitID= 10" 'same thing happens with using above query
Try
connection.Open()
adapter = New SqlDataAdapter(sql, connection)
adapter.Fill(ds)
connection.Close()
ds.WriteXml("Product.xml")
它添加了< NewDataSet>
<表格>
< xmltest>
it adds <NewDataSet>
<Table>
<xmltest>
和格式都压缩了.
我们的vb.net应用程序将报告另存为pdf,将其转换为b64,然后应使用创建正确格式的xml文件并将其发送出去.
Our vb.net application saves report as pdf, converts it to b64 and then it should use create properly formatted xml file and send it out.
谢谢
阿米尔
推荐答案
http://www.dotnetcurry.com/linq/564/linq-to-xml-tutorials-examples
http://www.dotnetcurry.com/linq/564/linq-to-xml-tutorials-examples
这篇关于不添加数据集的XML输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!