473,624 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to append header to XML file generated using BCP in SQL

6 New Member
I am generating XML files using FOR XML AUTO, ELEMENTS with BCP in SQL Query. When I try to open an the XML file in browser, I get an error that "Only one Top level element is allowed in an XML document". I am assuming the XML document is missing the header line <?xml version="1.0" ........etc etc.

How do I append this header to the XML file in the run time ?

Images of Error, XML in Notepad, and typical Table I would to create from XML.
http://www.fiu.edu/~atmakurk/kk/XML_Error.jpg
http://www.fiu.edu/~atmakurk/kk/XML_View.jpg
http://www.fiu.edu/~atmakurk/kk/Table_View1.jpg

The SQL Query I am using is below:

Declare @SQuery nvarchar(3000)

Set @SQuery = 'bcp "EXEC test..free_Cust omsDistrict_HS4 _TEST [2006exp], 21, 6, 2" QueryOut "' + @fName + '" -c -t, -T'

Exec master..xp_cmds hell @SQuery



I am a new to XML and also newbie programmer. What I am really trying to do with the XML files is to display them as tables in webpages.
I would appreciate if anyone can direct me how to proceed ? How do I retrevie the XML file from Front End (ASP.NET) ?
Aug 31 '07 #1
2 4716
jkmyoung
2,057 Recognized Expert Top Contributor
What the error refers to is not having a root element. Eg, the following would be invalid as an xml document:
Expand|Select|Wrap|Line Numbers
  1. <row>
  2.   <value>1</value>
  3. </row>
  4. <row>
  5.   <value>2</value>
  6. </row>
You'd need to wrap these elements in a root element like so:
Expand|Select|Wrap|Line Numbers
  1. <table><row>
  2.   <value>1</value>
  3. </row>
  4. <row>
  5.   <value>2</value>
  6. </row>
  7. </table>
You have multiple d elements at the root level.
Aug 31 '07 #2
miamikk
6 New Member
I fixed the problem by adding ROOT option in the FOR XML part.
Aug 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

16
12526
by: matthurne | last post by:
I just started learning C++ on my own...I'm using Accelerated C++. Something it hasn't explained and I keep wondering about is how header files actually work. I suspect it doesn't get into it because it is, as the authors love to say, "implementation specific". If that's the case, how does the compiler commonly handle them? I use Linux and gcc specifically. Basically, I don't understand how a header file being included makes a...
11
2746
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do understand the objective. This example may represent an interface in need of a bit of refactoring, but it goes to demonstrate the basic idea as I understand it. http://developer.kde.org/documentation/library/cvs-api/kdevelop/html/ast_8h-source.html...
60
8263
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header associated with this source file For example, in a file hello.c: #include <stdio.h>
4
2513
by: Andrew Ward | last post by:
Hi All, I was wondering if it is possible to use precompiled headers without having to include a <stdafx.h> or whatever in every source file. My problem is that I have a project that makes heavy usage of a large third party library which means after pre-processing each translation unit is around 1meg in size. There are reasons though why I cannot use the standard approach to precompiled headers. What I would like to do is somthing like...
0
3927
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
1
1723
by: Lauchlan M | last post by:
Hi. I have an ASP.net project that works fine. I copied it to another project using the following steps: << (i) create a new VS.NET ASP.NET project.
0
4664
by: Daniel Thune, MCSE | last post by:
I am having a problem with formatting a SOAP Header in a .Net client. The client calls a Java Axis 1.1 based web service. In order to authenticate the caller, the web service call is intercepted by another web service that validates a security token in the header. I have pasted my current SOAP message that my code sends as captured from a trace function that I added. Below that is a sample SOAP message that the developer of the web...
1
1424
by: Greg | last post by:
Hi, In a C++/CLR Windows Forms app I notice that there is only a header and no ..cpp for the form. Also event handler bodies are added by the IDE right to the header. What is the philosophy on this? 1. Are C++ and/or C++/CLR classes now intended to be typically implemented in the header?
12
4254
by: vj | last post by:
I am using Borland C++. I run a program which generates output data files, say 'Voltage.dat', 'Current.dat'. I have a variable in my code (say N), and for various values of N (for each value of N), I generate these output data files. After running the program once for a given value of N (say N equal to 1) and when the programme is finished, I manually append the generated filename with the value of N, such as 'Voltage_N1.dat',...
0
8234
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8677
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.