XML Help

M

Mike Fellows

Im using a XmlTextWriter to create an xml document however the
doucmentation for the XML document that I have been given wants me to
create a xml document with the following:

<OrderType Code='STC'>Stock Check</OrderType>

how do I add the code='STC' to the Start Element?

Thanks

Mike Fellows
 
M

Martin Honnen

Mike said:
Im using a XmlTextWriter to create an xml document however the
doucmentation for the XML document that I have been given wants me to
create a xml document with the following:

<OrderType Code='STC'>Stock Check</OrderType>

how do I add the code='STC' to the Start Element?

It is an attribute with name "Code" and value "STC":

writer.WriteStartElement("OrderType")
writer.WriteAttributeString("Code", "STC")
writer.WriteString("Stock Check")
writer.WriteEndElement()
 
M

Mike Fellows

It is an attribute with name "Code" and value "STC":

writer.WriteStartElement("OrderType")
writer.WriteAttributeString("Code", "STC")
writer.WriteString("Stock Check")
writer.WriteEndElement()

Thanks for that I was just playing with that same code however i always end
up with double quoation marks " when the document spec lists '

It might work

Thanks again
 
M

Martin Honnen

Mike said:
Thanks for that I was just playing with that same code however i always end
up with double quoation marks " when the document spec lists '

XML allows single or double quotes to be used to delimit attribute
values, it does not make any difference in terms of the semantics of the
XML whether single or double quotes are used.

XmlTextWriter has a property named QuoteChar that you can set as needed,
if you really think you need single quote delimiters.
 
J

Joe Cool

@TK2MSFTNGP03.phx.gbl:








Thanks for that I was just playing with that same code however i always end  
up with double quoation marks " when the document spec lists '

It might work

Double quotes are the standard delimiters for attribute values in XML.
 
J

Joe Cool

XML allows single or double quotes to be used to delimit attribute
values, it does not make any difference in terms of the semantics of the
XML whether single or double quotes are used.

XmlTextWriter has a property named QuoteChar that you can set as needed,
if you really think you need single quote delimiters.

I found it interesting that if you force single quotes with, say, a
text editor, then open the xml in IE, IE translates the single qotes
to double quotes.
 
M

Martin Honnen

Joe said:
I found it interesting that if you force single quotes with, say, a
text editor, then open the xml in IE, IE translates the single qotes
to double quotes.

Well IE uses an XSL stylesheet to transform the XML into a HTML document
rendering a tree of the XML document with some script to allow
collapsing and expanding nodes. As the data model the XSL stylesheet
works on does only store nodes of a certain type like element nodes and
attribute nodes but certainly not any delimiters used in the markup
source it is not surprising that the view IE presents does not preserve
any such source details.
 
M

Mike Fellows

Well IE uses an XSL stylesheet to transform the XML into a HTML document
rendering a tree of the XML document with some script to allow
collapsing and expanding nodes. As the data model the XSL stylesheet
works on does only store nodes of a certain type like element nodes and
attribute nodes but certainly not any delimiters used in the markup
source it is not surprising that the view IE presents does not preserve
any such source details.


Thanks for all the replies, I have it working perfectly now

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Edit XML File 1
xml woes 1
XML 2
XML LINQ - output to XMLtextwriter - the headaches... 2
xslt and .net 1
XML schema error 1
XML DTDs Versus XML Schema 0
add a node to XMLDocument 1

Top