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

single quote xml value

EvtEnrollAttr.Value = "3748"
EvtEnrollElem.Attributes.Append(EvtEnrollAttr)

i need the attr value to be <stuff ID = '3748'> in single quote

how can i do that with visual basic.net?

thanks

Jun 26 '06 #1
8 2780
Use EvtEnrollAttr.Value = "'3748'" (single quote's inside double quote)

"dotnetnoob" <do********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
EvtEnrollAttr.Value = "3748"
EvtEnrollElem.Attributes.Append(EvtEnrollAttr)

i need the attr value to be <stuff ID = '3748'> in single quote

how can i do that with visual basic.net?

thanks

Jun 27 '06 #2
dotnetnoob wrote:
EvtEnrollAttr.Value = "3748"
EvtEnrollElem.Attributes.Append(EvtEnrollAttr)

i need the attr value to be <stuff ID = '3748'> in single quote

how can i do that with visual basic.net?


Use QuoteChar property of the XmlTextWriter class:
http://msdn2.microsoft.com/en-us/lib...quotechar.aspx
--
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Jun 27 '06 #3
i got error Cannot set a value on node type 'Element'. when i try single
quote inside double quote.

is there an example of how to use textwriter quotechar?

thank

"Sanjib Biswas" wrote:
Use EvtEnrollAttr.Value = "'3748'" (single quote's inside double quote)

"dotnetnoob" <do********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
EvtEnrollAttr.Value = "3748"
EvtEnrollElem.Attributes.Append(EvtEnrollAttr)

i need the attr value to be <stuff ID = '3748'> in single quote

how can i do that with visual basic.net?

thanks


Jun 27 '06 #4
ok, i figure out the error and by using single quote inside double quote i
got this value

<EventEnrollment InstanceNumber="'3748'">

it is still not the result that i want i need it to be '3748'

thanks

"Sanjib Biswas" wrote:
Use EvtEnrollAttr.Value = "'3748'" (single quote's inside double quote)

"dotnetnoob" <do********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
EvtEnrollAttr.Value = "3748"
EvtEnrollElem.Attributes.Append(EvtEnrollAttr)

i need the attr value to be <stuff ID = '3748'> in single quote

how can i do that with visual basic.net?

thanks


Jun 27 '06 #5


dotnetnoob wrote:

is there an example of how to use textwriter quotechar?

Here is a simple example with C#:

XmlTextWriter xmlWriter = new XmlTextWriter(@"file.xml",
System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.QuoteChar = '\'';
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("EventEnrollment");
xmlWriter.WriteAttributeString("InstanceNumber", "3748");
xmlWriter.WriteEndDocument();
xmlWriter.Close();

file.xml then has the contents

<?xml version='1.0' encoding='utf-8'?>
<EventEnrollment InstanceNumber='3748' />

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '06 #6
how do you insert it into the specific area of the xml file. i have done it
with DOM, but i just can't get the attribute value to go from double quote to
single quote. here is my code

Dim newEvtEnrollElem As XmlElement = Nothing
Dim str1, str2 As String

str1 = strPath.Substring(0, strPath.LastIndexOf("."))
str2 = str1.ToString.Remove(0, 42)

Dim wrtr As XmlTextWriter = New XmlTextWriter("C:\" + str2 + ".xml",
Encoding.Unicode)

newEvtEnrollElem =
CType(xDoc.SelectSingleNode("AutomationControl/EventEnrollments"), XmlElement)

str1 = strPath.Substring(0, strPath.LastIndexOf("."))
str2 = str1.ToString.Remove(0, 42)

If newEvtEnrollElem IsNot Nothing Then
Dim EvtEnrollElem As XmlElement =
xDoc.CreateElement("EventEnrollment")
Dim EvtEnrollAttr As XmlAttribute =
xDoc.CreateAttribute("InstanceNumber")

EvtEnrollAttr.Value = "'\'" + "3748" + "'\'"
EvtEnrollElem.Attributes.Append(EvtEnrollAttr)

EvtEnrollElem.InnerXml =
"<BackwardReferences/><EventEnrollmentProperties><EnabledReference/><EventParameters><SetpointReference/></EventParameters><EventSources/></EventEnrollmentProperties><GeneralProperties><Desc ription/></GeneralProperties>"

Dim EvtEnrollProp_AckRequiredAttrNode As XmlAttribute =
xDoc.CreateAttribute("AckRequired")
EvtEnrollProp_AckRequiredAttrNode.Value = "0"
Dim EvtEnrollProp_EvtEnabledAttrNode As XmlAttribute =
xDoc.CreateAttribute("EventEnable")
EvtEnrollProp_EvtEnabledAttrNode.Value = "0"
Dim EvtEnrollProp_EvtTypeAttrNode As XmlAttribute =
xDoc.CreateAttribute("EventType")
EvtEnrollProp_EvtTypeAttrNode.Value = "0"
Dim EvtEnrollProp_NotifyClassAttrNode As XmlAttribute =
xDoc.CreateAttribute("NotifyClass")
EvtEnrollProp_NotifyClassAttrNode.Value = "0"
Dim EvtEnrollProp_NotifyTypeAttrNode As XmlAttribute =
xDoc.CreateAttribute("NotifyType")
EvtEnrollProp_NotifyTypeAttrNode.Value = "0"
Dim EvtEnrollProp_PresentValueAttrNode As XmlAttribute =
xDoc.CreateAttribute("PresentValue")
EvtEnrollProp_PresentValueAttrNode.Value = "0"
Dim EvtEnrollProp_ToFaultTextAttrNode As XmlAttribute =
xDoc.CreateAttribute("ToFaultText")
EvtEnrollProp_ToFaultTextAttrNode.Value = ""
Dim EvtEnrollProp_ToNormalTextAttrNode As XmlAttribute =
xDoc.CreateAttribute("ToNormalText")
EvtEnrollProp_ToNormalTextAttrNode.Value = ""
Dim EvtEnrollProp_ToOffNormalTextAttrNode As XmlAttribute =
xDoc.CreateAttribute("ToOffNormalText")
EvtEnrollProp_ToOffNormalTextAttrNode.Value = ""
EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_AckRequiredAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_EvtEnabledAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_EvtTypeAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_NotifyClassAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_NotifyTypeAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_PresentValueAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_ToFaultTextAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_ToNormalTextAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").Se tAttributeNode(EvtEnrollProp_ToOffNormalTextAttrNo de)

Dim EnRef_ObjKeyAttrNode As XmlAttribute =
xDoc.CreateAttribute("ObjectKey")
EnRef_ObjKeyAttrNode.Value = ""
Dim EnRef_PropName As XmlAttribute =
xDoc.CreateAttribute("PropertyName")
EnRef_PropName.Value = ""
EvtEnrollElem.Item("EventEnrollmentProperties").It em("EnabledReference").SetAttributeNode(EnRef_ObjK eyAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EnabledReference").SetAttributeNode(EnRef_Prop Name)

Dim EvtPara_BitMaskAttrNode As XmlAttribute =
xDoc.CreateAttribute("BitMask")
EvtPara_BitMaskAttrNode.Value = "0"
Dim EvtPara_DeadbandAttrNode As XmlAttribute =
xDoc.CreateAttribute("Deadband")
EvtPara_DeadbandAttrNode.Value = ""
Dim EvtPara_HighDiffLimitAttrNode As XmlAttribute =
xDoc.CreateAttribute("HighDiffLimit")
EvtPara_HighDiffLimitAttrNode.Value = ""
Dim EvtPara_HighLimitAttrNode As XmlAttribute =
xDoc.CreateAttribute("HighLimit")
EvtPara_HighLimitAttrNode.Value = ""
Dim EvtPara_ListOfBitStringValuesAttrNode As XmlAttribute =
xDoc.CreateAttribute("ListOfBitStringValues")
EvtPara_ListOfBitStringValuesAttrNode.Value = ""
Dim EvtPara_ListOfValuesAttrNode As XmlAttribute =
xDoc.CreateAttribute("ListOfValues")
EvtPara_ListOfValuesAttrNode.Value = ""
Dim EvtPara_LowDiffLimitAttrNode As XmlAttribute =
xDoc.CreateAttribute("LowDiffLimit")
EvtPara_LowDiffLimitAttrNode.Value = ""
Dim EvtPara_LowLimitAttrNode As XmlAttribute =
xDoc.CreateAttribute("LowLimit")
EvtPara_LowLimitAttrNode.Value = ""
Dim EvtPara_RefPropIncrAttrNode As XmlAttribute =
xDoc.CreateAttribute("ReferencedPropertyIncrement" )
EvtPara_RefPropIncrAttrNode.Value = "1"
Dim EvtPara_TimeDelayAttrNode As XmlAttribute =
xDoc.CreateAttribute("TimeDelay")
EvtPara_TimeDelayAttrNode.Value = "60"
Dim EvtPara_TimeIntervalAttrNode As XmlAttribute =
xDoc.CreateAttribute("TimeInterval")
EvtPara_TimeIntervalAttrNode.Value = "1"
EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Bit MaskAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Dea dbandAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Hig hDiffLimitAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Hig hLimitAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Lis tOfBitStringValuesAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Lis tOfValuesAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Low DiffLimitAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Low LimitAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Ref PropIncrAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Tim eDelayAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").SetAttributeNode(EvtPara_Tim eIntervalAttrNode)

Dim SetPointRef_ObjKeyAttrNode As XmlAttribute =
xDoc.CreateAttribute("ObjectKey")
SetPointRef_ObjKeyAttrNode.Value = ""
Dim SetPointRef_PropNameAttrNode As XmlAttribute =
xDoc.CreateAttribute("PropertyName")
SetPointRef_PropNameAttrNode.Value = ""
EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").Item("SetpointReference").Se tAttributeNode(SetPointRef_ObjKeyAttrNode)

EvtEnrollElem.Item("EventEnrollmentProperties").It em("EventParameters").Item("SetpointReference").Se tAttributeNode(SetPointRef_PropNameAttrNode)

Dim GP_AttrNode As XmlAttribute = xDoc.CreateAttribute("Attr")
GP_AttrNode.Value = "0"
Dim GP_InstNumAttrNode As XmlAttribute =
xDoc.CreateAttribute("InstanceNumber")
GP_InstNumAttrNode.Value = "3748"
Dim GP_IsConfigAttrNode As XmlAttribute =
xDoc.CreateAttribute("IsConfigured")
GP_IsConfigAttrNode.Value = "0"
Dim GP_ObjNameAttrNode As XmlAttribute =
xDoc.CreateAttribute("ObjectName")
GP_ObjNameAttrNode.Value = "test1"
Dim GP_ObjTypeAttrNode As XmlAttribute =
xDoc.CreateAttribute("ObjectType")
GP_ObjTypeAttrNode.Value = "9"
Dim GP_SchemaVerAttrNode As XmlAttribute =
xDoc.CreateAttribute("SchemaVer")
GP_SchemaVerAttrNode.Value = "1.4"
Dim GP_TraceOptionsAttrNode As XmlAttribute =
xDoc.CreateAttribute("TraceOptions")
GP_TraceOptionsAttrNode.Value = "0"
EvtEnrollElem.Item("GeneralProperties").SetAttribu teNode(GP_AttrNode)

EvtEnrollElem.Item("GeneralProperties").SetAttribu teNode(GP_InstNumAttrNode)

EvtEnrollElem.Item("GeneralProperties").SetAttribu teNode(GP_IsConfigAttrNode)

EvtEnrollElem.Item("GeneralProperties").SetAttribu teNode(GP_ObjNameAttrNode)

EvtEnrollElem.Item("GeneralProperties").SetAttribu teNode(GP_ObjTypeAttrNode)

EvtEnrollElem.Item("GeneralProperties").SetAttribu teNode(GP_SchemaVerAttrNode)

EvtEnrollElem.Item("GeneralProperties").SetAttribu teNode(GP_TraceOptionsAttrNode)

newEvtEnrollElem.AppendChild(EvtEnrollElem)

End If

xDoc.WriteTo(wrtr)
wrtr.Close()
MessageBox.Show("Added new eventenrollment element")
"Martin Honnen" wrote:


dotnetnoob wrote:

is there an example of how to use textwriter quotechar?

Here is a simple example with C#:

XmlTextWriter xmlWriter = new XmlTextWriter(@"file.xml",
System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.QuoteChar = '\'';
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("EventEnrollment");
xmlWriter.WriteAttributeString("InstanceNumber", "3748");
xmlWriter.WriteEndDocument();
xmlWriter.Close();

file.xml then has the contents

<?xml version='1.0' encoding='utf-8'?>
<EventEnrollment InstanceNumber='3748' />

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Jun 27 '06 #7
Can someone help? is it possible to switch the value from double quote to
single quote without using the xmltextwriter quotechar

"dotnetnoob" wrote:
EvtEnrollAttr.Value = "3748"
EvtEnrollElem.Attributes.Append(EvtEnrollAttr)

i need the attr value to be <stuff ID = '3748'> in single quote

how can i do that with visual basic.net?

thanks

Jun 27 '06 #8


dotnetnoob wrote:
how do you insert it into the specific area of the xml file. i have done it
with DOM, but i just can't get the attribute value to go from double quote to
single quote. here is my code Dim wrtr As XmlTextWriter = New XmlTextWriter("C:\" + str2 + ".xml",
Encoding.Unicode)


If you save with that XmlTextWriter then doing e.g.
wrtr.QuoteChar = "'"C
should suffice. Obviously that will use the single quote on any
attribute, I don't think there is a way to have just one attribute value
quoted with ' and others with ".

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '06 #9

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

Similar topics

4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
3
by: Jim in Arizona | last post by:
Is there an easy way to just get a single value from a database and put it into a string? This is as far as I can get: Dim TKEY As String TKEY = dlShowRequests.DataKeys(e.Item.ItemIndex) ...
8
by: Johs | last post by:
In Pratical C++ Programming by Steve Oualline (O'Reilly) I found this code example: #include <iostream.h> int result; // the result of the calculations char oper_char; // the user-specified...
4
by: fniles | last post by:
I am looping thru DataReader and constructing a sql query to insert to another database. When the data type of the field is string I insert the field value using a single quote. When the value of...
2
by: Reporter | last post by:
I got the following example from http://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/index.html : echo '<tr><td>First name:</td><td><input type="text" name="first_name"...
0
by: dhascuba | last post by:
The @name field can contain a single quote in it such as: Mike O'Grady. Since this is creating and SQL statement on the server side, it will not process the name if it has a single quote in it. Id'...
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
2
by: BobRoyAce | last post by:
I am using VB.NET and I have a variable that is defined as Nullable(Of Single) as follows: Dim fMyNullableSingle as Nullable(Of Single) Then, I have another variable as follows: Dim...
6
by: Nathan Sokalski | last post by:
I know that Single and Double can only store values that can be stored as x/2^y, such as 0.5 and 0.125. But when they attempt to store values such as 0.1 or 0.2 whose exact value cannot be stored,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
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...

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.