Exporting To XML File

P

PC Datasheet

AccessXP in 2000 mode.

I am running a procedure using Application.ExportXML. The XML file begins
with:
<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">
- <QryExportWOOnSelectedShowDate>

and I get the following between each record's data:
<QryExportWOOnSelectedShowDate>
-<QryExportWOOnSelectedShowDate>

Does anyone know if there is a way to prevent these entries in the XML file
so all the file contains is data?

Thanks!

Steve
 
L

Larry Linson

I suspect that what you are seeing is "well-formed XML" -- why would you
want to eliminate any part of it to make it "not-so-well-formed"? Does it
not import properly into the target application, and you have determined
that it is these particular markup items that prevent it doing so?

If all you want is data, you could use comma-delimited text (aka
comma-separated-variable, CSV) instead.

The only reason to use XML, generally, is that the data is going to an
application that accepts XML. Otherwise, you'd want to export in some other
format.

Larry Linson
Microsoft Access MVP
 
G

Gary Walter

PC Datasheet said:
AccessXP in 2000 mode.

I am running a procedure using Application.ExportXML. The XML file begins
with:
<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">
- <QryExportWOOnSelectedShowDate>

and I get the following between each record's data:
<QryExportWOOnSelectedShowDate>
-<QryExportWOOnSelectedShowDate>

Does anyone know if there is a way to prevent these entries in the XML
file so all the file contains is data?
Hi Steve,

One small part of my job is to take University
Line Schedule data and print a report to a pdf
file. I use pdf995 which allows adding Bookmarks
after report has printed if they are in a "xml" file
which is not "well-formed."

As I print the report, I save Page number,
College, and Dept in a table.

I then run a function that writes this data
to the "xml" file in form they require by
opening a file for output, cycling through
a recordset to table above, and printing
lines to the file.

So...it's not difficult to "do-it-yourself."
If you'd like, I could post the code, but
the "form" of the output is specific to
pdf995 bookmarks.

I'm curious though as to how you would expect to
"header" a record in your xml....

gary
 
D

Dirk Goldgar

PC Datasheet said:
AccessXP in 2000 mode.

I am running a procedure using Application.ExportXML. The XML file
begins with:
<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">
- <QryExportWOOnSelectedShowDate>

Actually, the dashes that precede the tags are an artifact of Internet
Explorer, reflecting the expansion of a hierarchical node structure --
they aren't in the XML file itself, as you'll see if you edit it in
Notepad.
and I get the following between each record's data:
<QryExportWOOnSelectedShowDate>
-<QryExportWOOnSelectedShowDate>

Does anyone know if there is a way to prevent these entries in the
XML file so all the file contains is data?

Those tags, which I expect are really <QryExportWOOnSelectedShowDate>
.... data elements ... </QryExportWOOnSelectedShowDate>, are required by
the XML structure. Each pair marks the beginning and end of an element
of the document being represented by the XML file. In this case, the
element is a record. You can't get rid of them and still have a
well-formed XML document.
 
P

PC Datasheet

Hi Gary,

Thanks for your response! Dirk Goldgar (who also responded to this thread)
pointed me to the Application,ExportXML method in AccessXP. I used it to
export a query to XML. Now I may sound a little like I know what I am
talking about but it's a facade. I created a routine to export a series of
queries to XML. It worked; the files were in the specified folder but I know
nothing else about XML. So you ask what I would expect to "header" a record
in my xml... I can't answer that because I do no know what you are speking
about. What does it mean to "header" a record?

Thanks again, Gary!

Steve
 
P

PC Datasheet

Thanks for the information, Dirk! BTW, I got Application.ExportXML to work
and created a routine to export a series of queries.

Steve
 
D

Dirk Goldgar

PC Datasheet said:
Thanks for the information, Dirk! BTW, I got Application.ExportXML to
work and created a routine to export a series of queries.

I guessed as much. You're welcome.
 
G

Gary Walter

Hi Steve,

I imagine you probably understood better
from Dirk's sage response, but just in case...

Suppose I had a table called Books. Two records
might look like:

Author: John L. Viescas
Title: Building Microsoft Access Applications
ISBN: 0-7356-2039-3
Pub: Microsoft Press
Edition: 2005

Author: Ken Henderson
Title: The Guru's Guide to Transact-SQL
ISBN: 0-201-615760-2
Pub: Addison-Wesley
Edition: 2000

At its very basic, XML is a markup language
that will allow you to produce your hierarchy of
records using beginning and ending tags
(which *you* can define).

It might be loosely analogous with you setting
up headers and footers in an Access report.

In our example, we might define the "header and
footer" tags for a book record as

<book>


</book>

then within each book "header/footer" tag set, we use similar
tags for each fieldname within the record and the field
values go between those tags. At its simplest form,
our XML file might look like:

<book>
<Author>John L. Viescas</Author>
<Title> Building Microsoft Access Applications</Title>
<ISBN> 0-7356-2039-3</ISBN>
<Pub> Microsoft Press</Pub>
<Edition> 2005</Edition>
</book>

<book>
<Author>Ken Henderson</Author>
<Title> The Guru's Guide to Transact-SQL</Title>
<ISBN> 0-201-615760-2</ISBN>
<Pub> Addison-Wesley</Pub>
<Edition> 2000</Edition>
</book>

In your export, it looks like the
process chose to use your query
name for the "header/footer" tags
of a record

<QryExportWOOnSelectedShowDate>
......
......
</QryExportWOOnSelectedShowDate>

I am not an XML expert. It gets a lot more
complicated when you throw in powerful
namespaces, style sheets, and formatting,
but a "well-formed" XML file all starts with
the basics above.

good luck,

gary

{I probably should not have confused
things by using "header" in my original
response...sorry}
 
D

Danny J. Lesandrini

Steve, try this code to create some pure xml for any table ...


Function CreatePage(sTable As String) As String

Dim mydb As Database
Dim rst As Recordset
Dim fld As Field
Dim strText As String


Set mydb = CurrentDb
Set rst = mydb.OpenRecordset(sTable, dbOpenSnapshot)

strText = "<?xml version=""1.0""?>" & vbcrlf & vbcrlf
strText = strText & "<" & sTable & ">" & vbcrlf

With rst
Do Until .EOF
For Each fld In rst.Fields
strText = strText & " <" & fld.Name & ">" & rst(fld.Name) & "</" & fld.Name & ">" & vbcrlf
Next
strText = strText & vbcrlf
.MoveNext
Loop
End With
strText = strText & "</" & sTable & ">" & vbcrlf

Set rst = Nothing
Set mydb = Nothing

CreatePage = strText

End Function
 
P

PC Datasheet

First, thanks to all of you!

I'm taking a shortcut here ---

WHAT ARE the big uses of XML? What are the advantages?

Thanks,

Steve
 
D

Douglas J. Steele

One use I'm seeing more and more of is as a replacement for INI files, since
it allows you to organize the data much easier. In situations where you have
multiple possibilities for a particular value, XML allows you the equivalent
of an array, which (assuming your program checks for the possibility) is
easier than having to check multiple keys.

It's also more reliable for simple text data than csv or fixed-width.

Overall, though, I find it tends to be more "verbose" than the alternatives.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top