xml-attribute

How to use XmlElementAttribute for List<T>?

我与影子孤独终老i 提交于 2019-12-04 05:54:26
I have a class like this: public class Level { [XmlAttribute] public string Guid { get; set; } } public class LevelList : List<Level> { } public class Test { public LevelList CalLevelList { get; set; } } Using XmlSerializer, I get the output like this: <CalLevelList> <Level Guid="0de98dfb-ce06-433f-aeae-786b6d920aa6"/> <Level Guid="0de98dfb-ce06-433f-aeae-786b6d920aa7"/> </CalLevelList> Which is technically correct. However, without changing the class names, I'd like to make the output look like this: <Levels> <L Guid="0de98dfb-ce06-433f-aeae-786b6d920aa6"/> <L Guid="0de98dfb-ce06-433f-aeae

How do I give an array an attribute during serialization in C#?

做~自己de王妃 提交于 2019-12-04 00:34:09
I'm trying to generate C# that creates a fragment of XML like this. <device_list type="list"> <item type="MAC">11:22:33:44:55:66:77:88</item> <item type="MAC">11:22:33:44:55:66:77:89</item> <item type="MAC">11:22:33:44:55:66:77:8A</item> </device_list> I was thinking of using something like this: [XmlArray( "device_list" ), XmlArrayItem("item")] public ListItem[] device_list { get; set; } as the property, with this class declaration: public class ListItem { [XmlAttribute] public string type { get; set; } [XmlText] public string Value { get; set; } } Which gives me the inner serialization, but

Golang: how to unmarshal XML attributes with colons?

蹲街弑〆低调 提交于 2019-12-03 00:06:43
Some SVG/XML files I'm working with have dashes and colons in attribute names - for example: <g> <a xlink:href="http://example.com" data-bind="121">...</a> </g> I'm trying to figure out how to unmarshal these attributes using golang 's encoding/xml package. While the dashed attributes works, the ones with the colon doesn't: [ See here for a live example ] package main import ( "encoding/xml" "fmt" ) var data = ` <g> <a xlink:href="http://example.com" data-bind="121">lala</a> </g> ` type Anchor struct { DataBind int `xml:"data-bind,attr"` // this works XlinkHref string `xml:"xlink:href,attr"` /

IPAD xml parsing with attributes deal

给你一囗甜甜゛ 提交于 2019-12-02 19:44:11
问题 <category name="Local"> … … … <category name="business"> … … … <category name="politics"> … … … This is my xml file, I'm not sure how to deal with attribute i am using NSXMLParser. My question is how to deal with above attributes in NSXMLParser. Please help me. Thanks in advance. 回答1: You should have a look at parser:didStartElement:namespaceURI:qualifiedName:attributes:. The names are then in the attributes dictionary. Edit: If the following doesn't help you, you should read some

IPAD xml parsing with attributes deal

倾然丶 夕夏残阳落幕 提交于 2019-12-02 09:35:41
<category name="Local"> … … … <category name="business"> … … … <category name="politics"> … … … This is my xml file, I'm not sure how to deal with attribute i am using NSXMLParser. My question is how to deal with above attributes in NSXMLParser. Please help me. Thanks in advance. You should have a look at parser:didStartElement:namespaceURI:qualifiedName:attributes: . The names are then in the attributes dictionary. Edit: If the following doesn't help you, you should read some introduction stuff. - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:

XML: attributes or children? [duplicate]

孤街浪徒 提交于 2019-12-02 02:55:10
问题 This question already has answers here : XML attribute vs XML element (20 answers) Closed 3 years ago . In XSD, SOAP and other XML conventions you'll often see things like: <book> <title>Harry Potter</title> <author>J.K. Rowling</author> </book> Now I'm wondering, what happened to attributes? To me it makes more sense to write this as: <book title="Harry Potter" author="J.K. Rowling" /> But apparently, for some reason, smarter people than me chose otherwise. Could someone explain why, and

XML: attributes or children? [duplicate]

安稳与你 提交于 2019-12-02 02:33:37
This question already has an answer here: XML attribute vs XML element 20 answers In XSD, SOAP and other XML conventions you'll often see things like: <book> <title>Harry Potter</title> <author>J.K. Rowling</author> </book> Now I'm wondering, what happened to attributes? To me it makes more sense to write this as: <book title="Harry Potter" author="J.K. Rowling" /> But apparently, for some reason, smarter people than me chose otherwise. Could someone explain why, and what attributes are for then? Some people consider the difference a matter of personal preference. There are a few guidlines out

How to preserve whitespace within an element's opening tag in XSLT

只谈情不闲聊 提交于 2019-12-02 02:25:55
问题 In order to avoid committing sensitive information to an SCM repository, I wrote an XSL stylesheet that removes connection string passwords from ASP.NET Web.config files. It achieves my goal of removing passwords, but it also affects the whitespace within the opening tags of elements. I would like to preserve this whitespace if possible. For example, given this Web.config : <configuration> <connectionStrings> <add name="ApplicationServices" connectionString="Host=localhost;Username=dev

Add new users in SSAS security

﹥>﹥吖頭↗ 提交于 2019-12-01 20:58:45
I want to add users in SSAS security using following XMLA script. DECLARE @CreateUserInSsasXMLA VARCHAR(MAX) = '<Batch AllowCreate="true" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine" Transaction="true"> <Alter ObjectExpansion="ObjectProperties" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine"> <Object /> <Object> <RoleID>Administrators</RoleID> </Object> <ObjectDefinition> <Role xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns

Why isn't my document validating as XHTML 1.1 STRICT?

痞子三分冷 提交于 2019-12-01 17:24:47
问题 While target="_blank" is deprecated, why is the W3C validator not giving an error about this ? You can paste and check this code int the validator: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p> <a href="http://www.stackoverflow.com" title="New window will open" target="