Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a namespace to XML output

Status
Not open for further replies.

dkwaters

Programmer
Feb 16, 2003
17
0
0
GB
Hi,

I have the following code that creates an XML file.

AdoCn = New SqlConnection(DSN)
AdoCn.Open()
SQLAdap = New SqlDataAdapter(SQL, AdoCn)
SQLAdap.Fill(DataS, WebServiceID)
SQLAdap.Dispose()
DataS.WriteXml(XMLPath)

This outputs the following XML file:

<?xml version="1.0" standalone="yes" ?>
- <datareader>
- <_x0031_088>
<UserName>uname</UserName>
<Password>pwd</Password>
<Event_ID>43687</Event_ID>
<Spirit_ID>17219</Spirit_ID>
<EstablishmentFullName>Gravesend Grammar School</EstablishmentFullName>
<Postcode>DA12 2PR</Postcode>
<Type_ID>10</Type_ID>
<Sub_Type>A: Active</Sub_Type>
<UserName1>Jason Gould</UserName1>
<StartDate>30/Aug/2004 00:00:00</StartDate>
<Due_Date>01/Sep/2004 00:00:00</Due_Date>
<Priority>1</Priority>
<Status>A</Status>
<Event_Name>TEST</Event_Name>
<ActionUser>Jason Gould</ActionUser>
<ActionDate>01/Sep/2004 00:00:00</ActionDate>
<MarketingAuditId>27494</MarketingAuditId>
</_x0031_088>
- <_x0031_088>
<UserName>uname</UserName>
<Password>pwd</Password>
<Event_ID>43687</Event_ID>
<Spirit_ID>17219</Spirit_ID>
<EstablishmentFullName>Gravesend Grammar School</EstablishmentFullName>
<Postcode>DA12 2PR</Postcode>
<Type_ID>10</Type_ID>
<Sub_Type>A: Active</Sub_Type>
<UserName1>Jason Gould</UserName1>
<StartDate>30/Aug/2004 00:00:00</StartDate>
<Due_Date>01/Sep/2004 00:00:00</Due_Date>
<Priority>1</Priority>
<Status>A</Status>
<Event_Name>TEST</Event_Name>
<ActionUser>Barbara Spork</ActionUser>
<Narrative>wrfewgwr</Narrative>
<ActionDate>30/Aug/2004 11:31:26</ActionDate>
<MarketingAuditId>27495</MarketingAuditId>
</_x0031_088>
</datareader>

However I want the output to look like this

<?xml version="1.0" standalone="yes" ?>
- <datareader xmlns="- <_x0031_088>
<UserName>uname</UserName>
<Password>pwd</Password>
<Event_ID>43687</Event_ID>
<Spirit_ID>17219</Spirit_ID>
<EstablishmentFullName>Gravesend Grammar School</EstablishmentFullName>
<Postcode>DA12 2PR</Postcode>
<Type_ID>10</Type_ID>
<Sub_Type>A: Active</Sub_Type>
<UserName1>Jason Gould</UserName1>
<StartDate>30/Aug/2004 00:00:00</StartDate>
<Due_Date>01/Sep/2004 00:00:00</Due_Date>
<Priority>1</Priority>
<Status>A</Status>
<Event_Name>TEST</Event_Name>
<ActionUser>Jason Gould</ActionUser>
<ActionDate>01/Sep/2004 00:00:00</ActionDate>
<MarketingAuditId>27494</MarketingAuditId>
</_x0031_088>
- <_x0031_088>
<UserName>uname</UserName>
<Password>pwd</Password>
<Event_ID>43687</Event_ID>
<Spirit_ID>17219</Spirit_ID>
<EstablishmentFullName>Gravesend Grammar School</EstablishmentFullName>
<Postcode>DA12 2PR</Postcode>
<Type_ID>10</Type_ID>
<Sub_Type>A: Active</Sub_Type>
<UserName1>Jason Gould</UserName1>
<StartDate>30/Aug/2004 00:00:00</StartDate>
<Due_Date>01/Sep/2004 00:00:00</Due_Date>
<Priority>1</Priority>
<Status>A</Status>
<Event_Name>TEST</Event_Name>
<ActionUser>Barbara Spork</ActionUser>
<Narrative>wrfewgwr</Narrative>
<ActionDate>30/Aug/2004 11:31:26</ActionDate>
<MarketingAuditId>27495</MarketingAuditId>
</_x0031_088>
</datareader>

Note: I have added the namespace xmlns=" at the top by the datareader opening tag.

I have had a search around but can't find anything obvious.

thanks
 
After you write the XML file, open it and do a search for "<datareader>" and replace it with "<datareader xmlns=" then resave the file.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top