473,383 Members | 1,953 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,383 software developers and data experts.

Creating an XML Document to return from function

Ok, I've spent all this time creating a program to read an XML Document via
XPaths and my boss is pretty thrilled, but now I have to return an XML
document, so can someone point me to some sample code that creates an XML
Doc and adds a field/element to it?

Thanx!

--
TFWBWY...A
Dec 9 '05 #1
4 2395
Bryan:

The following KB article may be a useful reference, depending on your exact
needs.

http://support.microsoft.com/default...b;en-us;317665

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Ok, I've spent all this time creating a program to read an XML Document via
XPaths and my boss is pretty thrilled, but now I have to return an XML
document, so can someone point me to some sample code that creates an XML
Doc and adds a field/element to it?

Thanx!

--
TFWBWY...A

Dec 9 '05 #2
I think that's close, but I'm still grappling with trying to understand some
of the details and how to translate them to my situation. All that to say,
I don't get it yet.

If I want to pass back a very simple XML Document that looks like this:

<?xml version="1.0" encoding="UTF-16" ?>
<Results>
<OrderNumber>123456</OrderNumber>
<Error>[Error messages, if any, go here]</Error>
</Results>

.... what would a sample piece of code look like?

Thanx!
"David Lloyd" <Da***@NoSpamPlease.com> wrote in message
news:%z**************@bignews7.bellsouth.net...
Bryan:

The following KB article may be a useful reference, depending on your
exact
needs.

http://support.microsoft.com/default...b;en-us;317665

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or
warranties.
"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Ok, I've spent all this time creating a program to read an XML Document
via
XPaths and my boss is pretty thrilled, but now I have to return an XML
document, so can someone point me to some sample code that creates an XML
Doc and adds a field/element to it?

Thanx!

--
TFWBWY...A

Dec 9 '05 #3
Bryan:

The following code sample would create a similar document.

Private Sub btnXML_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnXML.Click

Dim doc As XmlDocument = New XmlDocument

Dim dec As XmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-16",
String.Empty)
Dim eResults As XmlNode = doc.CreateElement("Results")

doc.InsertBefore(dec, doc.DocumentElement)

doc.AppendChild(eResults)

Dim eOrderNum As XmlNode = doc.CreateElement("OrderNumber")

eOrderNum.InnerText = "123456"

eResults.AppendChild(eOrderNum)

Dim eError As XmlNode = doc.CreateElement("Error")

eError.InnerText = "[Error messages, if any, go here]"

eResults.AppendChild(eError)

doc.Save(("C:\TestXML.xml"))

End Sub
--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
I think that's close, but I'm still grappling with trying to understand some
of the details and how to translate them to my situation. All that to say,
I don't get it yet.

If I want to pass back a very simple XML Document that looks like this:

<?xml version="1.0" encoding="UTF-16" ?>
<Results>
<OrderNumber>123456</OrderNumber>
<Error>[Error messages, if any, go here]</Error>
</Results>

.... what would a sample piece of code look like?

Thanx!
"David Lloyd" <Da***@NoSpamPlease.com> wrote in message
news:%z**************@bignews7.bellsouth.net...
Bryan:

The following KB article may be a useful reference, depending on your
exact
needs.

http://support.microsoft.com/default...b;en-us;317665

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or
warranties.
"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Ok, I've spent all this time creating a program to read an XML Document
via
XPaths and my boss is pretty thrilled, but now I have to return an XML
document, so can someone point me to some sample code that creates an XML
Doc and adds a field/element to it?

Thanx!

--
TFWBWY...A


Dec 10 '05 #4
Thanx! That was exactly what I needed!

"David Lloyd" <Da***@NoSpamPlease.com> wrote in message
news:r1****************@bignews5.bellsouth.net...
Bryan:

The following code sample would create a similar document.

Private Sub btnXML_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnXML.Click

Dim doc As XmlDocument = New XmlDocument

Dim dec As XmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-16",
String.Empty)
Dim eResults As XmlNode = doc.CreateElement("Results")

doc.InsertBefore(dec, doc.DocumentElement)

doc.AppendChild(eResults)

Dim eOrderNum As XmlNode = doc.CreateElement("OrderNumber")

eOrderNum.InnerText = "123456"

eResults.AppendChild(eOrderNum)

Dim eError As XmlNode = doc.CreateElement("Error")

eError.InnerText = "[Error messages, if any, go here]"

eResults.AppendChild(eError)

doc.Save(("C:\TestXML.xml"))

End Sub
--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or
warranties.
"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
I think that's close, but I'm still grappling with trying to understand
some
of the details and how to translate them to my situation. All that to
say,
I don't get it yet.

If I want to pass back a very simple XML Document that looks like this:

<?xml version="1.0" encoding="UTF-16" ?>
<Results>
<OrderNumber>123456</OrderNumber>
<Error>[Error messages, if any, go here]</Error>
</Results>

... what would a sample piece of code look like?

Thanx!
"David Lloyd" <Da***@NoSpamPlease.com> wrote in message
news:%z**************@bignews7.bellsouth.net...
Bryan:

The following KB article may be a useful reference, depending on your
exact
needs.

http://support.microsoft.com/default...b;en-us;317665

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or
warranties.
"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Ok, I've spent all this time creating a program to read an XML Document
via
XPaths and my boss is pretty thrilled, but now I have to return an XML
document, so can someone point me to some sample code that creates an XML
Doc and adds a field/element to it?

Thanx!

--
TFWBWY...A


Dec 12 '05 #5

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

Similar topics

20
by: svend | last post by:
I'm messing with some code here... Lets say I have this array: a1 = ; And I apply slice(0) on it, to create a copy: a2 = a1.slice(0); But this isn't a true copy. If I go a1 = 42, and then...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
6
by: NotGiven | last post by:
I want to learn moer of what I saw in a recent example. They create a page that created new fields/element. It's not like they were hidden and they displayed them, they were not there, then the...
24
by: jonathon | last post by:
Hi all, I have a web app with a popup window for entering data. I don't want to access the web every time this window is opened, as most of the app is AJAX. But I can't figure out how to open...
6
by: Adam Tilghman | last post by:
Hi all, I have found that IE doesn't seem to respect the <SELECT> "multiple" attribute when set using DOM methods, although the attribute/property seems to exist and is updated properly. Those...
2
by: SAL | last post by:
I would like to create a VB.net function, that builds a dynamic hyperlink using System.Web.UI.WebControls.HyperLink, but I can not find any examples on how to generate a dynamic hyperlink. Has...
4
by: deadlyicon | last post by:
So I wanted an object to have a reference to a string in side of an array some where else and so here is how I made that possible: <div id="something"> </div> <script> var obj =...
1
by: Rako | last post by:
My problem is: I want to create an index to any of the available picture-groups. This index is a table of thumbs with a scrollbar. If you click on the thumb, you get the full picture displayed. ...
6
by: cleary1981 | last post by:
I have adapted code from http://dunnbypaul.net/js_mouse/ I want to use a button to create new draggable divs but i keep getting error "is null or not an object" heres the code <html> <head>...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.