Xml data bound to Datagridview -> Add datarow via XmlElement

Greetings,

I have a datagridview bound to a datatable created from an xmlfile on one 
form.

Another form appends to the xml file using the code below.
To refresh the datagridview on the other form I simply re-set the datasource 
to the newly saved xmldocument.

However, is it possible to use the XmlQuoteEl.outerxml as it includes all 
the information which equates to a datarow to add it to the datatable 
(datagridview datasource)?

XmlElement isn't an acceptble parameter in any read/write xml methods, but 
thought re-loading the whole file again is overkill.

Hope this makes sense, to summarise can I use the contents of 
XmlQuoteEl.outerxml  and insert it into the datatable as a datarow?


'Load xml data into the instance of xmldocument created above

quotedoc.Load(cQuoteFileName)

'Create the root node element i.e. quotefile for a NEW quote

Dim xmlQuoteEl As XmlElement = quotedoc.CreateElement("quote")

'Create nodes under the root element

xmlQuoteEl.InnerXml = 
"<date></date><author></author><category></category><text></text>"

'Set details for quote

xmlQuoteEl.Item("date").InnerText = dtpQuoteDate.Value.ToString("dd MMMM 
yyyy")

xmlQuoteEl.Item("author").InnerText = txtAuthor.Text

xmlQuoteEl.Item("category").InnerText = cboCategory.SelectedItem.ToString

xmlQuoteEl.Item("text").InnerText = txtQuote.Text

'append the whole element to the whole damn document.

quotedoc.DocumentElement.AppendChild(xmlQuoteEl)

'save the document now!

quotedoc.Save(cQuoteFileName)


Thanks
Rob 


0
Rob
11/24/2009 3:24:02 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
2148 Views

Similar Articles

[PageSpeed] 24

Well I've made a start

Dim reader As New System.IO.StringReader(xmlQuoteEl.OuterXml)

Dim dd As New DataSet

dd.ReadXml(reader)



"Rob W" <robwha@o2.co.uk> wrote in message 
news:%23xL63oRbKHA.6028@TK2MSFTNGP04.phx.gbl...
> Greetings,
>
> I have a datagridview bound to a datatable created from an xmlfile on one 
> form.
>
> Another form appends to the xml file using the code below.
> To refresh the datagridview on the other form I simply re-set the 
> datasource to the newly saved xmldocument.
>
> However, is it possible to use the XmlQuoteEl.outerxml as it includes all 
> the information which equates to a datarow to add it to the datatable 
> (datagridview datasource)?
>
> XmlElement isn't an acceptble parameter in any read/write xml methods, but 
> thought re-loading the whole file again is overkill.
>
> Hope this makes sense, to summarise can I use the contents of 
> XmlQuoteEl.outerxml  and insert it into the datatable as a datarow?
>
>
> 'Load xml data into the instance of xmldocument created above
>
> quotedoc.Load(cQuoteFileName)
>
> 'Create the root node element i.e. quotefile for a NEW quote
>
> Dim xmlQuoteEl As XmlElement = quotedoc.CreateElement("quote")
>
> 'Create nodes under the root element
>
> xmlQuoteEl.InnerXml = 
> "<date></date><author></author><category></category><text></text>"
>
> 'Set details for quote
>
> xmlQuoteEl.Item("date").InnerText = dtpQuoteDate.Value.ToString("dd MMMM 
> yyyy")
>
> xmlQuoteEl.Item("author").InnerText = txtAuthor.Text
>
> xmlQuoteEl.Item("category").InnerText = cboCategory.SelectedItem.ToString
>
> xmlQuoteEl.Item("text").InnerText = txtQuote.Text
>
> 'append the whole element to the whole damn document.
>
> quotedoc.DocumentElement.AppendChild(xmlQuoteEl)
>
> 'save the document now!
>
> quotedoc.Save(cQuoteFileName)
>
>
> Thanks
> Rob
> 


0
Rob
11/24/2009 9:53:09 PM
Reply:

Similar Artilces:

automatically add email address to contacts when replying mail in outlook 2003 #3
every time i send a reply or email to sometime how can i tweak outlook 2003 to save the email address to my contacts automatically?? - Thank you Mayur Mayur Patel <patelmb@vt.edu> wrote: > every time i send a reply or email to sometime how can i tweak > outlook 2003 to save the email address to my contacts automatically?? http://www.slipstick.com/contacts/addauto.htm -- Brian Tillman ...

Xml web services step by step tutorial
Hi all, I am a newbie for web service and i would like to develop the web service directory like uddi or strikeiron.com based on the web service technology. COuld any one show me step by step to do so, what i really need to know and how to do so. THank you so much. A really great book is Professional ASP.NET Web Services with VB.Net by Wrox "Popoxinhxan" <Popoxinhxan@discussions.microsoft.com> wrote in message news:E99E9635-D5A1-42A7-B8F0-6139356E98E1@microsoft.com... > Hi all, > I am a newbie for web service and i would like to develop the web service directory like ...

Dataset.WriteXml does NOT produce well formed XML
For example: =========================== Dim filename As String filename = Server.MapPath("./") & "xml/dataSet.xml" Dim myFileStream As New System.IO.FileStream(filename, IO.FileMode.Create) Dim myXmlWriter As New System.Xml.XmlTextWriter (myFileStream, System.Text.Encoding.Unicode) objDataSet.WriteXml(myXmlWriter) myXmlWriter.Close() ============================ Thus, if there is data in the dataset with a string such as: "Where are my < & > ESCAPE sequences?" The resulting XML will look like: <foo>Where are my < & > ESCAP...

restrict data in combo box
I have a combo box that lists returns. The returns can be open or closed. I want the user to be able to restrict the data in the combo box if they check the [ckOpen] check box. I've tried several ways but none of them work. Any help would be appreciated. Combo box query: SELECT tReturns.MerchandiseReturnNo, tReturns.VendorName, tReturns.VendorID, tReturns.Description, tReturns.ReturnDate, tReturns.COGAccountNo, tReturns.ReturnAmount, tReturns.Status, tReturns.CompanyID, tReturns.MerchandiseReturnNo, IIf([Forms]! [fReturns]![ckOpen]=True,[Status]="Open","*") AS ReturnOp...

ANNOUNCE: v2007 of Altova XML software available
Altova is pleased to announce the availability of Version 2007 of its XML product line. Version 2007 provides numerous new features and updates, including a revolutionary new WSDL editor in XMLSpy=C2=AE, the ability to use Web services as sources, targets, or functions in MapForce=C2=AE data integration projects, output sorting in StyleVision=C2= =AE, a major speed increase in the AltovaXML=E2=84=A2 processor built into the products, and much more. In addition, limited time offers allow customers to save up to 52% when they upgrade to XMLSpy 2007 from an older version, or get a free license fo...

Combining data from multiple sheets
I have been using OmniPage 12 to scan columnar data and then export it to Excel. So far I have had reasonable success with the OCR formatting but when exporting the data, each scanned sheet becomes a sheet in Excel. I want all the data on one sheet so that I can manipulate it (sort, pivot, etc.). I have had no luck with help at the OmniPage bulletin board so I thougt, alternatively, is there a way to combine data from multiple sheets that would be simpler than copy/paste. Hi Ron - Have you tried going from the other direction? If OmniPage allows you to save the files as Text (I beli...

How do I add musical score (adding my own notes) to publisher
The intention is to add trebel or base musical score to MS Publisher brochure and be able to add notes to it, i.e. I wish to reproduce a hymn in a church bulletin. SB wrote: > The intention is to add trebel or base musical score to MS Publisher brochure > and be able to add notes to it, i.e. I wish to reproduce a hymn in a church > bulletin. Microsoft Publisher is not a scorewriting program. Technically, you could put in some ClipArt musical notes or WordArt/text if you have the fonts available, but you would be much better off using a dedicated scorewriter and then exporting...

Considering cells colored via conditional formatting
EXCEL 2007 Any piece of code which, for example, select or count the cells which are colored yellow, amongst the currently selected range, because of meeting ANY criteria of CONDITIONAL FORMATTING. In other words, considering cells which are not actually possessing yellow as an interior color but being displayed so because of CONDITIONAL FORMATTING. -- Thanx in advance, Best Regards, Faraz There are two pages at Chip Pearson's wepage that you need to look at. the 2nd gives a detailed example of how to do what you want. 'Conditional Formatting' (http:/...

VB to XML?
I have an Access db app that I made, I want to put in a webpage, how do I go about this, do I use XML .NET ASP? The more detailed information the better. I am clueless. thanks. ...

How to add a disclaimer at the bottom of all outgoing messages
I would like to add a standard text at the bottom of every message sent to external address. I have both Exchange 2000 and 2003. I do not want to use the signature feature in Outlook, but prefer to do it at the exchange level which will apply to all users. Hi You have two options here, you can either Follow MS article q317608 to create an SMTP Transport Event Sync, see here: http://support.microsoft.com/?scid=kb;en-us;317680 Second option: purchase a product such as GFI MailEssentials Regards -- Ben Hoffman MCP (Win2k Pro&Svr, Exchange 2003 Admin) http://www.ExchangeIS.com "...

Receiving XML Documents
Hi, I'm setting up a service that receives a XML document, validates the document using a schema and then returns a simple result. I wanted to ask what the best way is of doing this, that is sending the xml document. So far I've come across 2 way's: 1. Create a webservice that accepts a XMLNode. 2. Use HttpWebRequest to send the document as a stream. The service would be written in .NET but the clients can be written in any programing language. Thanks, EG elguapo, Since interoperability is important in your case (your #2 requirement), it is not suggested that you send any d...

XML samples for replace a child element
Hi, Does anybody know where I can find samples to search an element in a subtree of an xml file and replace some new value for this element? I can only find some samples to use 'replace last child or replade first child' but couldn't find sample for replace a child neither first nor last child. Thanks for any help, CT See http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemXmlXmlNodeClassReplaceChildTopic.asp Rather than specifying root.FirstChild or root.LastChild, you only need to select a particular node. Supposing you have the root node of the dom document (r...

XML Request & Response & ASP.NET 2.0
Hi, I would like to know like in ASP.NET 2.0 or .net version 2.0, how do I parse the XML and consume it?. right now I am using the old methods like XML DOM. second thing is I need to send a XML Request to some URL, inturn I will be getting the response Back in the form of XML ONLY. HOW TO SEND THE XML request in Version 2.0? I am using old method like HttpWebRequest & HttpWebResponse bye thanks, ss ss wrote: > I would like to know like in ASP.NET 2.0 or .net version 2.0, how do I parse > the XML and consume it?. > > right now I am using the old methods like XML...

Error in set up data source
I'm using Windows XP and Office 2K. I tried to set up a data source connecting to an Acces table. When I picked the fields to be included in my query, I got the 'Syntax error in FROM clause' error prompt. The same resulted for connecting to an Excel table but there was no such problem for connection to a dBase (.dbf) file. Any idea? -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 100,000 Newsgroups - 19 Different Servers! =----- ...

Write-Output of XML value has type format like "System.Xml.X..."
Hi, I want to output some value using Write-Output or Write-Host along with some comments. After reading the xml file and while executing the write-output command, its not printing the value, its printing the variable type along with xml structure not the value :( Please let me know how to print the correct output. See below the example for details. --------------------------------------------------------------------------------------------------------------------------- Variable.xml ------------------------------------------------------------------------------------...

messy data
Hi All, I have a problem with splitting some messy data and was hoping that someone could help me! I have a field which looks like this below: category6-category5-category4-category3-category2-category1 which I want to turn into this below, but in there own seperate columns: A B C D E F category1 category2 category3 category4 category5 category6 NOW, the problem is that sometimes the field doesn't go all the way to category6, it can go down to as little as category1 or category2 so would look like the below: category2-cate...

Get data out of a dataset.
Hi all! I use a dataset.ReadXML() to fill a dataset with data. With this I get different tables and relations availible in my dataset. What I�m wondering is: wich is the easy way to go here if I want to get specific values with "childvalues" via relations, out of this. Like a kind of sql:s "join" or something. /Marre Just an idea... if you fill a DataSet and then save the contents to disk as a Diffgram, using: DataSet.WriteXml(fileName, XmlWriteMode.Diffgram), you can see what the XML that is required to create the keys and relations looks like. ...

including dblink in a query to retrieve data
I connect to a table using a db link i want to execute an spl query and populate results in to a pivo table. My MS Query does not allow me to use a dblink and connect to th table. Please help -- Message posted from http://www.ExcelForum.com ...

"MSXML2.ServerXMLHTTP" add 'HTTP' in front of all request parameter
Hi, I need to write a ASPX file that will post some request to other party (web service written in java), here is my code, <%@ Page aspcompat=true %> <% Dim xml, url xml = Server.CreateObject("MSXML2.ServerXMLHTTP") url = "http://localhost/Testing.aspx" xml.Open ("POST", url, False) xml.SetRequestHeader ("status","1" ) xml.SetRequestHeader ("ref_id","5354" ) xml.SetRequestHeader ("response_type","MT" ) xml.Send () Response.Write (xml.responsetext) xml = not...

Exclusion List for Data Validation??
Hello! I have cells that require an entry (last names of people), so I have the validation set up for text >1 and <1000. This is good if the user decides to leave it blank, but if they put in a space, or two spaces, or more, or put in words like "none" "N/A" "unknown", etc, those responses are unacceptable. So how can I set up validation to allow for any entry except for blanks, spaces, or a list of words that I will constantly have to adjust as users get more creative? Thanks! VR/ Lost It would be really difficult to try and trap *every possible* ille...

Formatting Col C based on data in Col B
I have to format a report every day that is imported from SQL to Excel. My problem is that I am stuck on trying to "insert" text descriptions in Column C based on what is in Column B. The number of rows may vary from day to day (ie: one day the report is 315 rows and the next it may be 278 or 480). So, the total range of Col B would extend from (B2:end) on any given day. In plain language, If any of the data in Range (B:B) begins with "ML*" insert UPPERCASE "ABC" in Col C2 or If any of the data in Range(B:B) begins with "W*" insert UPPERCASE ...

Ghost Data/Large Operation
I have inherited a spreadsheet from a former coworker. In this spreadsheet, I cannot add or remove column(s)/row(s) without getting the "Large Operation" message indicating 'this is going to take forever to accomplish and are you sure you want to do this?' That's even for one column or row. I'm almost positive it has something to do with this sheet thinking that the last cell of data is EI1046599 even though there is no data in many thousands of rows and several dozen columns up to that point. My normal solution for this type of situation is to copy al...

MSCRM tools for data deduplication
Hi ppl, We are looking to use it for a potential MSCRM project for a large entreprise customer. The customer has multiple sources of customer data (over 5 databases), and what we are trying to achieve is to build a single source of customer data (ie, a customer master database in MSCRM). As there are multiple sources of customer data, there are many duplicate customer records. (eg, records could be in format such as Anthony Smith, Tony Smith, Toni Smith, etc). What we plan to do is to write some data conversion scripts using the MSCRM Data Migration Framework to load data from these datab...

Query to count between list of number (Predicting Start/End that may occur in data range)
Hi, I have a below list of numbers. 566667 566668 566669 566665 566666 566671 566672 566680 I want a query that would return a count between start and end of range. Like Start End Quantity 566665 566669 5 566671 566672 2 566680 566680 1 Thank you. On 2 apr, 07:17, Angela <ims...@gmail.com> wrote: > Hi, > > I have a below list of numbers. > > 566667 > 566668 > 566669 > 566665 > 566666 > 566671 > 566672 > 566680 > > I want a query that would return a coun...

Select data for plot
I want to create a simple line chart for each project; but need the ability for the user to not plot a particular project (Y 0r N) Proj1 Proj2 Proj3 Proj4 Y Y Y N 11.3% 8.5% 1.8% 0.9% 16.1% 12.4% 3.7% 1.5% 21.3% 16.6% 6.9% 3.9% Any ideas? Thanks Saintsman So far you have Proj1 through Proj4 Data. Add four more columns for Proj1 through Proj4 Chart. Assuming there is also a first column for some kind of categories or dates, Proj1 Data is column D, Proj1 Chart is column F, row 2 has the Y/N.... then put this formula in F3: =IF(B$2="Y",B3,NA()) fill this formula across to colu...