来自访问的xml [英] xml from access
问题描述
嗨!
我想使用VBA从访问中编译xml。以下工作非常好。但我希望rowsofreport是记录集中的do ---循环的结果。如何打破语句并插入do ---循环?
I would like to compile xml from access using VBA. the following works very well. but I would like the rowsofreport be a result of a do---loop in a recordset. how do I break the statement and insert the do---loop ?
&NBSP; docXMLDOM.loadXML"<?xml version ="" 1.0""编码= QUOT;" UTF-8英寸;" ?>" &安培; _
docXMLDOM.loadXML "<?xml version=""1.0"" encoding=""utf-8"" ?>" & _
"< v1:report_ready xmlns:v1 ="" http://www.e.."">" &安培; _
"<v1:report_ready xmlns:v1=""http://www......"">" & _
" <企业编码> 987321< /企业编码>" &安培; _
" <companycode>987321</companycode>" & _
" < periodyear>" &安培;表格!mydata!year& "< / periodyear>" &安培; _
" <periodyear>" & Forms!mydata!year & "</periodyear>" & _
" < periodmonth>" &安培;表格!mydata!month& "< / periodmonth>" &安培; _&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
" <periodmonth>" & Forms!mydata!month & "</periodmonth>" & _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; " < rowsofreport>" &安培; _
" <rowsofreport>" & _
&NBSP;&NBSP; "&NBSP; < reportrow>" &安培; _
" <reportrow>" & _
&NBSP;&NBSP; "&NBSP;&NBSP;&NBSP; <密码> 123456789< /密码>" &安培; _
" <passcode>123456789</passcode>" & _
&NBSP;&NBSP; "&NBSP;&NBSP;&NBSP; < prodtype> 100℃; / prodtype>" &安培; _
" <prodtype>100</prodtype>" & _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP; "&NBSP; < / reportrow>" &安培; _
" </reportrow>" & _
&NBSP;&NBSP; "&NBSP; < reportrow>" &安培; _
" <reportrow>" & _
&NBSP;&NBSP; "&NBSP;&NBSP; &NBSP;<密码> 987654321< /密码>" &安培; _
" <passcode>987654321</passcode>" & _
&NBSP;&NBSP; "&NBSP;&NBSP;&NBSP; < prodtype> 100℃; / prodtype>" &安培; _
" <prodtype>100</prodtype>" & _
&NBSP;&NBSP; "&NBSP; < / reportrow>" &安培; _
" </reportrow>" & _
&NBSP;&NBSP; "&NBSP; < reportrow>" &安培; _
" <reportrow>" & _
&NBSP;&NBSP; "&NBSP;&NBSP;&NBSP; <密码> 456123< /密码>" &安培; _
" <passcode>456123</passcode>" & _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;"&NBSP;&NBSP;&NBSP; < prodtype> 100℃; / prodtype>" &安培; _
" <prodtype>100</prodtype>" & _
&NBSP;&NBSP; "&NBSP; < / reportrow>" &安培; _
" </reportrow>" & _
&NBSP;&NBSP; " < / rowsofreport> " &安培; _
" </rowsofreport> " & _
&NBSP;&NBSP; "< / V1:report_ready>"
"</v1:report_ready >"
感谢您
推荐答案
您好,
一种方法是为报告行使用单独的变量,然后使用循环填充它,然后将其插入开始和结束XML文本。例如(在伪代码):
One approach is to use a separate variable for the report rows and then use the loop to populate it and then insert it between the beginning and ending XML text. For example (in pseudocode):
昏暗strReportRows作为字符串
Dim strReportRows As String
循环通过所有记录
strReportRows = strReportRows& " XML元素..."
strReportRows = strReportRows & "XML elements..."
接着记录
docXMLDOM.LoadXML = QUOT;<?XML版本...< rowsofreport> ;" &安培; strReportRows& "< / rowsofreport> ..."
docXMLDOM.LoadXML = "<?xml version... <rowsofreport>" & strReportRows & "</rowsofreport>..."
希望有所帮助......
Hope it helps...
这篇关于来自访问的xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!