Hi,
I am writing a maintenance site for my department. One of the pages
displays XML from the database in a GridView. I would like to be able
to edit the cell, which I can currently do, but parse the contents of
the cell when updating to make sure what is saved into the databse is
proper XML.
Any suggestions on how I could do this would be greatly appreciated.
Thanks 6 1536
On Aug 5, 9:00*pm, nomad <d.bedg...@o2.c o.ukwrote:
Hi,
I am writing a maintenance site for my department. *One of the pages
displays XML from the database in a GridView. *I would like to be able
to edit the cell, which I can currently do, but parse the contents of
the cell when updating to make sure what is saved into the databse is
proper XML.
Any suggestions on how I could do this would be greatly appreciated.
Thanks
Use the XmlDocument class.
XmlDocument doc = new XmlDocument();
string xmlData = .... from the database
doc.Load(new StringReader(xm lData));
XmlNodeList nodes = xml.SelectNodes ("//topic");
string prefix;
foreach (XmlNode node in nodes)
{
....
}
doc.Save(xmlDat a);
...save xmlData to the database http://msdn.microsoft.com/en-us/libr...ldocument.aspx
On Aug 5, 8:50*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:00*pm, nomad <d.bedg...@o2.c o.ukwrote:
Hi,
I am writing a maintenance site for my department. *One of the pages
displays XML from the database in a GridView. *I would like to be able
to edit the cell, which I can currently do, but parse the contents of
the cell when updating to make sure what is saved into the databse is
proper XML.
Any suggestions on how I could do this would be greatly appreciated.
Thanks
Use the XmlDocument class.
XmlDocument doc = new XmlDocument();
string xmlData = .... from the database
doc.Load(new StringReader(xm lData));
XmlNodeList nodes = xml.SelectNodes ("//topic");
string prefix;
foreach (XmlNode node in nodes)
{
....
}
doc.Save(xmlDat a);
...save xmlData to the database
http://msdn.microsoft.com/en-us/libr...ldocument.aspx
HI,
Thanks very much for your reply. I'm gathering by your code that by
doing doc.Load(new StringReader(xm lData)); it is basically parsing the
XML, and if this fails then I trap that error. If it successds then I
save the xmlData back into the database?
THanks for your time.
On Aug 5, 9:59*pm, nomad <d.bedg...@o2.c o.ukwrote:
On Aug 5, 8:50*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:00*pm, nomad <d.bedg...@o2.c o.ukwrote:
Hi,
I am writing a maintenance site for my department. *One of the pages
displays XML from the database in a GridView. *I would like to be able
to edit the cell, which I can currently do, but parse the contents of
the cell when updating to make sure what is saved into the databse is
proper XML.
Any suggestions on how I could do this would be greatly appreciated.
Thanks
Use the XmlDocument class.
XmlDocument doc = new XmlDocument();
string xmlData = .... from the database
doc.Load(new StringReader(xm lData));
XmlNodeList nodes = xml.SelectNodes ("//topic");
string prefix;
foreach (XmlNode node in nodes)
{
....
}
doc.Save(xmlDat a);
...save xmlData to the database
http://msdn.microsoft.com/en-us/libr...ldocument.aspx
HI,
Thanks very much for your reply. *I'm gathering by your code that by
doing doc.Load(new StringReader(xm lData)); it is basically parsing the
XML, and if this fails then I trap that error. *If it successds then I
save the xmlData back into the database?
THanks for your time.- Hide quoted text -
- Show quoted text -
I think it would save the XmlDocument... What I forgot to mention is
about special/escape characters in XML (is it what you trying to avoid
of?). Look at the following article
How to locate and replace special characters in an XML file with
Visual C# .NET http://support.microsoft.com/kb/316063
Hope this helps
On Aug 5, 9:18*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:59*pm, nomad <d.bedg...@o2.c o.ukwrote:
On Aug 5, 8:50*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:00*pm, nomad <d.bedg...@o2.c o.ukwrote:
Hi,
I am writing a maintenance site for my department. *One of the pages
displays XML from the database in a GridView. *I would like to beable
to edit the cell, which I can currently do, but parse the contents of
the cell when updating to make sure what is saved into the databse is
proper XML.
Any suggestions on how I could do this would be greatly appreciated..
Thanks
Use the XmlDocument class.
XmlDocument doc = new XmlDocument();
string xmlData = .... from the database
doc.Load(new StringReader(xm lData));
XmlNodeList nodes = xml.SelectNodes ("//topic");
string prefix;
foreach (XmlNode node in nodes)
{
....
}
doc.Save(xmlDat a);
...save xmlData to the database
>http://msdn.microsoft.com/en-us/libr...ldocument.aspx
HI,
Thanks very much for your reply. *I'm gathering by your code that by
doing doc.Load(new StringReader(xm lData)); it is basically parsing the
XML, and if this fails then I trap that error. *If it successds then I
save the xmlData back into the database?
THanks for your time.- Hide quoted text -
- Show quoted text -
I think it would save the XmlDocument... What I forgot to mention is
about special/escape characters in XML (is it what you trying to avoid
of?). Look at the following article
How to locate and replace special characters in an XML file with
Visual C# .NEThttp://support.microso ft.com/kb/316063
Hope this helps
Hi,
Thanks again for the prompt reply. What I'm basically after is that
if someone makes a change to the XML in the textbox, I want to verify
that it is well formed XML before saving it into the database. If
it's not well formed then I can display a message box, which I have
already written, explaining to the user that it's not valid XML. They
can then make the relevant change before saving it.
Hope that makes sense.
Really appreciate your help.
On Aug 5, 10:30*pm, nomad <d.bedg...@o2.c o.ukwrote:
On Aug 5, 9:18*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:59*pm, nomad <d.bedg...@o2.c o.ukwrote:
On Aug 5, 8:50*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:00*pm, nomad <d.bedg...@o2.c o.ukwrote:
Hi,
I am writing a maintenance site for my department. *One of the pages
displays XML from the database in a GridView. *I would like to be able
to edit the cell, which I can currently do, but parse the contents of
the cell when updating to make sure what is saved into the databse is
proper XML.
Any suggestions on how I could do this would be greatly appreciated.
Thanks
Use the XmlDocument class.
XmlDocument doc = new XmlDocument();
string xmlData = .... from the database
doc.Load(new StringReader(xm lData));
XmlNodeList nodes = xml.SelectNodes ("//topic");
string prefix;
foreach (XmlNode node in nodes)
{
....
}
doc.Save(xmlDat a);
...save xmlData to the database
http://msdn.microsoft.com/en-us/libr...ldocument.aspx
HI,
Thanks very much for your reply. *I'm gathering by your code that by
doing doc.Load(new StringReader(xm lData)); it is basically parsing the
XML, and if this fails then I trap that error. *If it successds then I
save the xmlData back into the database?
THanks for your time.- Hide quoted text -
- Show quoted text -
I think it would save the XmlDocument... What I forgot to mention is
about special/escape characters in XML (is it what you trying to avoid
of?). Look at the following article
How to locate and replace special characters in an XML file with
Visual C# .NEThttp://support.microso ft.com/kb/316063
Hope this helps
Hi,
Thanks again for the prompt reply. *What I'm basically after is that
if someone makes a change to the XML in the textbox, I want to verify
that it is well formed XML before saving it into the database. *If
it's not well formed then I can display a message box, which I have
already written, explaining to the user that it's not valid XML. *They
can then make the relevant change before saving it.
Hope that makes sense.
Really appreciate your help.- Hide quoted text -
- Show quoted text -
If you would edit it in the textbox, then you can simply use the
XmlTextReader: http://msdn.microsoft.com/en-us/libr...extreader.aspx
XmlReader r = new XmlTextReader(n ew StringReader(Te xtBox1.Text));
try {
while (r.Read())
{
//XML is well-formed
} catch (Exception e) {
//error
}
And if XML is not syntactically correct, the XML parser will raise an
error.
On Aug 5, 10:36*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 10:30*pm, nomad <d.bedg...@o2.c o.ukwrote:
On Aug 5, 9:18*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:59*pm, nomad <d.bedg...@o2.c o.ukwrote:
On Aug 5, 8:50*pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 5, 9:00*pm, nomad <d.bedg...@o2.c o.ukwrote:
Hi,
I am writing a maintenance site for my department. *One of the pages
displays XML from the database in a GridView. *I would like to be able
to edit the cell, which I can currently do, but parse the contents of
the cell when updating to make sure what is saved into the databse is
proper XML.
Any suggestions on how I could do this would be greatly appreciated.
Thanks
Use the XmlDocument class.
XmlDocument doc = new XmlDocument();
string xmlData = .... from the database
doc.Load(new StringReader(xm lData));
XmlNodeList nodes = xml.SelectNodes ("//topic");
string prefix;
foreach (XmlNode node in nodes)
{
....
}
doc.Save(xmlDat a);
...save xmlData to the database
>http://msdn.microsoft.com/en-us/libr...ldocument.aspx
HI,
Thanks very much for your reply. *I'm gathering by your code thatby
doing doc.Load(new StringReader(xm lData)); it is basically parsing the
XML, and if this fails then I trap that error. *If it successds then I
save the xmlData back into the database?
THanks for your time.- Hide quoted text -
- Show quoted text -
I think it would save the XmlDocument... What I forgot to mention is
about special/escape characters in XML (is it what you trying to avoid
of?). Look at the following article
How to locate and replace special characters in an XML file with
Visual C# .NEThttp://support.microso ft.com/kb/316063
Hope this helps
Hi,
Thanks again for the prompt reply. *What I'm basically after is that
if someone makes a change to the XML in the textbox, I want to verify
that it is well formed XML before saving it into the database. *If
it's not well formed then I can display a message box, which I have
already written, explaining to the user that it's not valid XML. *They
can then make the relevant change before saving it.
Hope that makes sense.
Really appreciate your help.- Hide quoted text -
- Show quoted text -
If you would edit it in the textbox, then you can simply use the
XmlTextReader:http://msdn.microsoft.com/en-us/libr...extreader.aspx
XmlReader r = new XmlTextReader(n ew StringReader(Te xtBox1.Text));
try {
while (r.Read())
{
//XML is well-formed
} catch (Exception e) {
//error
}
And if XML is not syntactically correct, the XML parser will raise an
error.
Thank you very much; that's exactly what I'm after. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ram Laxman |
last post by:
Hi all,
I have a text file which have data in CSV format.
"empno","phonenumber","wardnumber"
12345,2234353,1000202
12326,2243653,1000098
Iam a beginner of C/C++ programming.
I don't know how to tokenize the comma separated values.I used strtok
function reading line by line using fgets.but it gives some weird
behavior.It doesnot stripout the "" fully.Could any body have sample
code for the same so that it will be helfful for my...
|
by: |
last post by:
Hi,
I need to read a big CSV file, where different fields should be converted to
different types,
such as int, double, datetime, SqlMoney, etc.
I have an array, which describes the fields and their types. I would like
to somehow store a reference to parsing operations in this array
(such as Int32.Parse, Double.Parse, SqlMoney.Parse, etc),
so I can invoke the appropriate one without writing a long switch.
|
by: Jon Davis |
last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST"
The problem:
// this fails on PST
DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST");
Help?
Jon
|
by: Mark |
last post by:
How do you parse a currency string to a decimal? I'd like to avoid having
to parse the number out, removing the $ manually. That sounds like a hack.
There are times that this string will be currency and others when it will be
a text integer or decimal.
//This bombs because of the string having an improper format.
Decimal.Parse("$9,200.00")
Thanks in advance!
Mark
|
by: Jon Davis |
last post by:
I have put my users through so much crap with this bug it is an absolute
shame.
I have a product that reads/writes RSS 2.0 documents, among other things.
The RSS 2.0 spec mandates an en-US style of date formatting (RFC 822). I
have been using a variation of RFC 1123 (just change the time zone to an
offset, i.e. "-0800"). It seems to be writing okay, but it's failing to
parse.
I've tried changing the regional & language settings in my...
| |
by: Bob Rundle |
last post by:
I would like to get something like this to work...
Type t = FindMyType(); // might be int, float, double, etc
string s = "1233";
object v = t.Parse(s);
This doesn't work of couse, Parse is not a member of Type.
I have to think that this is possible. Is it?
|
by: Slonocode |
last post by:
I have some textboxes bound to an access db. I wanted to format the
textboxes that displayed currency and date info so I did the following:
Dim WithEvents oBidAmt As Binding
oBidAmt = New Binding("Text", Me.Ds1, "Items.BidAmt")
txtBidAmt.DataBindings.Add(oBidAmt)
Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
|
by: js |
last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss".
I need to parse the text using System.DateTime.Parse() function with
custom format. I got an error using the following code. Could someone
help me with the customization? Thanks.
String was not recognized as a valid DateTime. at
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles) at System.DateTime.Parse(String s,
IFormatProvider...
|
by: Samuel R. Neff |
last post by:
I'm using a quasi open-source project and am running into an exception
in double.Parse which is effectively this:
double.Parse(double.MinValue.ToString())
System.OverflowException: Value was either too large or too small for
a Double.
at System.Number.ParseDouble(String s, NumberStyles style,
NumberFormatInfo info)
|
by: Peter Duniho |
last post by:
I'm sure there's a good explanation for this, but I can't figure it out.
I tried using DateTime.Parse() with a custom DateTimeFormatInfo instance,
in which I'd replaced the DateTimeFormatInfo.FullDateTimePattern property
with my custom format string:
DateTimeFormatInfo dtfi =
(DateTimeFormatInfo)DateTimeFormatInfo.InvariantCulture.Clone();
dtfi.FullDateTimePattern = "dd/MMM/yyyy:HH:mm:ss zzz";
|
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,...
| |
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |