473,395 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Access 2003 XML help

I am trying to export an access 2003 query to XML and need to get it
to export in a very specific format. I am stuck and could use some
help badly (time is critical with this project).

This is what we have:

<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="order.xsd"
generated="2004-10-26T18:32:43">
- <order>
* <order_number>24158</order_number>
* <marketchannel>TIMCUST</marketchannel>
* <Ship_Method>GRD</Ship_Method>
* <Ship_To_Name>Some_Company_Name</Ship_To_Name>
* <Ship_To_Address_1>44 SW here ave</Ship_To_Address_1>
* <Ship_To_Address_2 />
* <Ship_To_City>WORCESTER</Ship_To_City>
* <Ship_To_State>MA</Ship_To_State>
* <Ship_To_Zip>01608</Ship_To_Zip>
* <Product_ID>1096.</Product_ID>
* <UOM>EACH</UOM>
* <Product_Quantity>4</Product_Quantity>
* </order>

This is what we need:

- <Orders>
* <customer_number>111111</customer_number>
* <total_line_items>4</total_line_items>
- <Order>
* <order_number>29381274</order_number>
* <marketchannel>SOME_MARKET_CHANNEL</marketchannel>
* <Ship_Method>FDG</Ship_Method>
* <Ship_To_Name>SHIP NAME</Ship_To_Name>
* <Ship_To_Address_1>SHIP ADDRESS 1</Ship_To_Address_1>
* <Ship_To_Address_2>SHIP ADDRESS 2</Ship_To_Address_2>
* <Ship_To_City>SHIP CITY</Ship_To_City>
* <Ship_To_State>CO</Ship_To_State>
* <Ship_To_Zip>12345</Ship_To_Zip>
- <Order_Line_Item>
* <Line_number>01</Line_number>
* <Product_ID>ITEM_CODE</Product_ID>
* <UOM>EA</UOM>
* <Product_Quantity>25</Product_Quantity>
* <Rush_Code>N</Rush_Code>
* </Order_Line_Item>
- <Order_Line_Item>
* <Line_number>02</Line_number>
* <Product_ID>ITEM_CODE</Product_ID>
* <UOM>EA</UOM>
* <Product_Quantity>50</Product_Quantity>
* <Rush_Code>N</Rush_Code>
* </Order_Line_Item>
* </Order>

The problem I have is the first few lines. I need to drop the first 4
lines as well as moving <customer_number> and <total_line_items> into
an <Orders> header as shown in the second sample.

How can I achieve this or is it even possible with Access?

Any help would be great.

Thanks
Nov 13 '05 #1
2 1889
XML is just a text file like an html file, or xsl, xsd, css, etc. Just
write out a text file the way you need it and give it a .xml extension.
You have the header section, just copy that from the wizard generated
file, then add the tags as you need based on your table column names,
and plant the data contents of each row field in between the tags (Note:
enclose your field names inside the angle brackets to create your tags -
unlikely you will need to specify CData constants and so forth).

To start with I would get a valid xml file that can be validated and is
well-formed. Copy all the xml into an Access Module as one string
variable. One long string, or several smaller strings. Write these
strings out to a text file. If you wrote the exact contents of the
original xml file to your new xml text file it should be well-formed and
should be validatable. Then you can do the same thing with your query.
Note: the query is dynamic. The xml file will be static.

This may seem tedious, but it is one possible solution.

HTH

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
Mark,

1. It uses ADO
2. There's a lot of extra stuff here
3. It exports html, not xml

But, the principle is the same. Hope it gives you a start.
Darryl Kerkeslager

---------------------------------------
Private Sub btnUpdatePDA_Click()
On Error GoTo handle_error
errText = " @ Start"
Dim cnxn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnxn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Dim charCounter As Long
Dim dq As String
Dim p As Long
Dim sOff As String
Dim vOff As String
Dim safeNotes As String
Dim safeTats As String
Dim filePhoto As String
dq = Chr$(34)

errText = " @ Offenders.html"
Open odisFolder & "offenders.html" For Output As #1
Print #1, "<html><body><center>District #" & GetDistrictID() & "
Offenders</center><center>ODIS v." & GetOdisVersion() & "</center><center>"
& Now() & "</center><hr/>"
For charCounter = 65 To 90
Print #1, "<input TYPE=" & dq & "button" & dq & " VALUE=" & dq &
Chr$(charCounter) & dq & "onClick=" & dq & "window.location.href='" &
Chr$(charCounter) & ".html'" & dq & "></input>"
Next charCounter
Print #1, "<input TYPE=" & dq & "button" & dq & " VALUE=" & dq &
"Fugitives" & dq & "onClick=" & dq & "window.location.href='fugitives.html'"
& dq & "></input>"
Print #1, "</body></html>"
Close #1

For charCounter = 65 To 90
Open odisFolder & Chr$(charCounter) & ".html" For Output As #1
Print #1, "<html><body>"

With rs
.Source = "SELECT * FROM PDAQuery" & InServer() & "WHERE off_name
Like '" & Chr(charCounter) & "%' ORDER BY off_name"
.Open , cnxn, adOpenForwardOnly, adLockReadOnly, adCmdText
errText = " @ Begin Query"
Do While Not .EOF
p = CLng(.Fields("offender_id"))
If .Fields("off_sex_offender") Then
sOff = "* Sex Offender"
Else
sOff = ""
End If
If .Fields("off_violent") Then
vOff = "* History of Violence"
Else
vOff = ""
End If
If IsNull(.Fields("off_tattoo")) Then
safeTats = ""
Else
safeTats = StrSafe(CStr(.Fields("off_tattoo")), Chr(34),
Chr(39))
End If
If IsNull(.Fields("cs_pda_notes")) Then
safeNotes = ""
Else
safeNotes = StrSafe(CStr(.Fields("cs_pda_notes")),
Chr(34), Chr(39))
End If
filePhoto = "/" & cardName & "/" & Format(Int(p / 1000),
"0000") & "/" & Format(p, "0000000") & "A.jpg"
frm.BottomMessage ("Data file: " & CStr(p) & ".html")
errText = " @ Open file"
Open odisFolder & CStr(p) & ".html" For Output As #2
Print #2, "<html><body><a name=" & dq & "T" & dq & "></a><a
href=" & dq & "#I" & dq & ">Identifiers</a> | <a href=" & dq & "#N" & dq &
">Notes</a> | <a href=" & dq & "#P" & dq & ">Photo</a><br/><br/>"
Print #2, "<b>" & RTrim(.Fields("off_name")) &
"</b><br/><hr/>"
If Len(Trim(.Fields("off_cur_location"))) > 0 Then Print #2,
..Fields("off_cur_location") & "<br/>"
Print #2, .Fields("off_address1") & "<br/>"
Print #2, .Fields("off_address2") &
"&nbsp;&nbsp;&nbsp;&nbsp;<b>Map: </b> " & .Fields("off_map_id") & "<br/>"
If Len(Trim(.Fields("off_cur_location"))) = 0 Then Print #2,
"<br/>"
Print #2, Nz(Format(.Fields("off_phone"), "(@@@) @@@-@@@@"),
"") & "<br/><br/>"
Print #2, "<b>PO: </b>" & .Fields("ppo_login") & "<br/>"
Print #2, "<b>Opened: </b>" & .Fields("cs_open_date") &
"<br/>"
Print #2, "<b>Last PC: </b>" & .Fields("cs_last_pc") &
"<br/>"
Print #2, "<b>PC Due: </b>" & .Fields("cs_pc_due") &
"<br/><br/>"
Print #2, sOff & "<br/>"
Print #2, vOff & "<br/>"
Print #2, "<b>Mental Health: </b>" & .Fields("mh_diagnosis")
& "<br/><br/><hr/>"
Print #2, "<a name=" & dq & "I" & dq & "></a>"
Print #2, .Fields("off_race") & "/" & .Fields("off_sex") &
"&nbsp;&nbsp;&nbsp;" & Format(.Fields("off_height"), "#'##") &
"&nbsp;&nbsp;&nbsp;" & .Fields("off_weight") & "lbs<br/>"
Print #2, "<b>Tattoos: </b>" & safeTats & "<br/><br/>"
Print #2, "<b>DOB: </b>" & .Fields("off_dob") & "<br/>"
Print #2, "<b>SSN: </b>" & Format(.Fields("off_ssn"),
"###-##-####") & "<br/>"
Print #2, "<b>Vaccis: </b>" & .Fields("offender_id").Value &
"<br/><br/>"
Print #2, "<a href=" & dq & "#T" & dq & ">Top</a><hr/><a
name=" & dq & "N" & dq & "></a>"
Print #2, "<b>Notes: </b>" & safeNotes & "<br/><br/><hr/>"
Print #2, "<a name=" & dq & "P" & dq & "></a>"
Print #2, "<img src=" & dq & filePhoto & dq & "><br/>"
Print #2, "<a href=" & dq & "#T" & dq &
">Top</a></body></html>"
Close #2
Print #1, "<a href=" & dq & .Fields("offender_id").Value &
".html" & dq & ">" & RTrim(.Fields("off_name")) & "</a><br>"
.MoveNext
Loop
.Close
End With
Print #1, "<br><br><a href=" & dq & "#TOP" & dq & ">Top of
Page</a></body></html>"
Close #1
Next charCounter
With rs
Open odisFolder & "fugitives.html" For Output As #3
Print #3, "<html><body>"
.Source = "SELECT offender_id, off_name FROM PDAQuery" & InServer() &
"WHERE cs_level = 'A' ORDER BY off_name"
.Open , cnxn, adOpenForwardOnly, adLockReadOnly, adCmdText
Do While Not .EOF
Print #3, "<a href=" & dq & .Fields("offender_id").Value &
".html" & dq & ">" & RTrim(.Fields("off_name")) & "</a><br>"
.MoveNext
Loop
.Close
Print #3, "<br><br><a href=" & dq & "#TOP" & dq & ">Top of
Page</a></body></html>"
Close #3
End With
Exit Sub
handle_error:
LogError Err.Number, "FieldContactForm.btnUpdatePDA", Err.Description &
errText
End Sub
"Mark" <by*******@hotmail.com> wrote:
I am trying to export an access 2003 query to XML and need to get it
to export in a very specific format. I am stuck and could use some
help badly (time is critical with this project).

This is what we have:

<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="order.xsd"
generated="2004-10-26T18:32:43">
- <order>
<order_number>24158</order_number>
<marketchannel>TIMCUST</marketchannel>
<Ship_Method>GRD</Ship_Method>
<Ship_To_Name>Some_Company_Name</Ship_To_Name>
<Ship_To_Address_1>44 SW here ave</Ship_To_Address_1>
<Ship_To_Address_2 />
<Ship_To_City>WORCESTER</Ship_To_City>
<Ship_To_State>MA</Ship_To_State>
<Ship_To_Zip>01608</Ship_To_Zip>
<Product_ID>1096.</Product_ID>
<UOM>EACH</UOM>
<Product_Quantity>4</Product_Quantity>
</order>

This is what we need:

- <Orders>
<customer_number>111111</customer_number>
<total_line_items>4</total_line_items>
- <Order>
<order_number>29381274</order_number>
<marketchannel>SOME_MARKET_CHANNEL</marketchannel>
<Ship_Method>FDG</Ship_Method>
<Ship_To_Name>SHIP NAME</Ship_To_Name>
<Ship_To_Address_1>SHIP ADDRESS 1</Ship_To_Address_1>
<Ship_To_Address_2>SHIP ADDRESS 2</Ship_To_Address_2>
<Ship_To_City>SHIP CITY</Ship_To_City>
<Ship_To_State>CO</Ship_To_State>
<Ship_To_Zip>12345</Ship_To_Zip>
- <Order_Line_Item>
<Line_number>01</Line_number>
<Product_ID>ITEM_CODE</Product_ID>
<UOM>EA</UOM>
<Product_Quantity>25</Product_Quantity>
<Rush_Code>N</Rush_Code>
</Order_Line_Item>
- <Order_Line_Item>
<Line_number>02</Line_number>
<Product_ID>ITEM_CODE</Product_ID>
<UOM>EA</UOM>
<Product_Quantity>50</Product_Quantity>
<Rush_Code>N</Rush_Code>
</Order_Line_Item>
</Order>

The problem I have is the first few lines. I need to drop the first 4
lines as well as moving <customer_number> and <total_line_items> into
an <Orders> header as shown in the second sample.

How can I achieve this or is it even possible with Access?

Any help would be great.

Thanks

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
2
by: BT Openworld | last post by:
I have just had to upgrade to Access 2003 as Access 97 EMail (SendObject) doesn't work when loaded on Windows XP. I'm finding my way around Access 2003 but my biggest problem is getting...
13
by: Noesis Strategy | last post by:
When I ordered my new laptop, Sony didn't offer Access 2003 in its bundles. Recently, I have begun to design Access databases using an copy of Access 2002 from my previous laptop. It works fine,...
3
by: Stickleback | last post by:
Morning All I have been developing and deploying with Office 2000 for about 3 years, mainly Access based programs and although I have gotten used to it's quirks, I am starting to feel that I...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
28
by: Neil Ginsberg | last post by:
I have a client who is using Access 2002/2000 (the database itself is written in 2000), and is considering migrating to Access 2003. Any recommendations on whether Access 2003 is worth the migrate,...
10
by: Lauren Wilson | last post by:
Ok I have searched the MS website for info on this. I am totally confused. If I want to deploy an Access 2003 app and allow my users to run it using Access 2003 Runtime, where do I get the...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
7
by: Cheryl Langdon | last post by:
Does anyone know if there is a way to globally turn off ALL control tips in Access 2003 using VBA code? Thanks. --- CL
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.