Daniel Wilson
asked on
.net XMLWriter and attributes
I'm using the XmlWriter class in .Net 2.0.
I'm trying to write the following bit of XML (it's part of a larger thing, but this is where I'm having a problem).
<Worksheet ss:Name="Sheet1">
The code below yields the error:
System.ArgumentException: Invalid name character in 'ss:Name'. The ':' character, hexadecimal value 0x3A, cannot be included in a name.
What do I need to do instead?
Thanks!
I'm trying to write the following bit of XML (it's part of a larger thing, but this is where I'm having a problem).
<Worksheet ss:Name="Sheet1">
The code below yields the error:
System.ArgumentException: Invalid name character in 'ss:Name'. The ':' character, hexadecimal value 0x3A, cannot be included in a name.
What do I need to do instead?
Thanks!
Private Sub XMLWorkSheetHeader(ByVal iResultNum As Int16, ByVal iRows As Int32, ByVal iColumns As Int16, ByRef W As XmlWriter)
W.WriteStartElement("Worksheet")
W.WriteAttributeString("ss:Name", "Sheet" & iResultNum)
You must add the proper declarations for the namespaces, otherwise this won't work.
ASKER
And those namespaces would be URI's? How do I know what URI to use?
I don't know what namespace you want to use. Probably something from microsoft's worksheets XML? You should use that namespace and declare it literally the same.
Otherwise (without a namespace) namespace prefixes (the parts before the colon) are illegal.
Otherwise (without a namespace) namespace prefixes (the parts before the colon) are illegal.
> How do I know what URI to use?
I don't know your application and I don't know why you want to write "ss:Name". Apparently that comes from somewhere else. Lookup that document and use the declaration from that document.
I don't know your application and I don't know why you want to write "ss:Name". Apparently that comes from somewhere else. Lookup that document and use the declaration from that document.
ASKER
In the header of the document I see stuff like
urn:schemas-microsoft-com: office:spr eadsheet
used.
Is that the kind of thing I should be using?
urn:schemas-microsoft-com:
used.
Is that the kind of thing I should be using?
ASKER
>>I don't know your application
I'm creating an XML spreadsheet from a data set and I want Excel to load it by default.
That's why I'm stuck on some funny-looking names -- I'm mimicking Excel's output.
Thanks for your help w/ this!
I'm creating an XML spreadsheet from a data set and I want Excel to load it by default.
That's why I'm stuck on some funny-looking names -- I'm mimicking Excel's output.
Thanks for your help w/ this!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Past that error & on to the next ... Thanks!
Good luck with the next then :)
You're welcome & thanks for the points!
You're welcome & thanks for the points!