XMLDictionary

XMLDictionary 提供一种简单的方法实现 iOS 和 Mac OS X 下解析和生成 XML 的方法。XMLDictionary 将 XML 转成 NSDictionary 。

实现用于优化 Windows Communication Foundation (WCF) 的 XML 读取器/编写器实现的字典。

命名空间:   System.Xml
程序集:  System.Runtime.Serialization(System.Runtime.Serialization.dll 中)

System.Object
System.Xml.XmlDictionary

C#
C++
F#
VB
public class XmlDictionary : IXmlDictionary

 名称说明
System_CAPS_pubmethodXmlDictionary()

创建一个空的 XmlDictionary

System_CAPS_pubmethodXmlDictionary(Int32)

创建具有初始容量的 XmlDictionary

 名称说明
System_CAPS_pubpropertySystem_CAPS_staticEmpty

获取 static IXmlDictionary

 名称说明
System_CAPS_pubmethodAdd(String)

将字符串添加到 XmlDictionary

System_CAPS_pubmethodEquals(Object)

确定指定的对象是否等于当前对象。(从 Object 继承。)

System_CAPS_protmethodFinalize()

在垃圾回收将某一对象回收前允许该对象尝试释放资源并执行其他清理操作。(从 Object 继承。)

System_CAPS_pubmethodGetHashCode()

作为默认哈希函数。(从 Object 继承。)

System_CAPS_pubmethodGetType()

获取当前实例的 Type(从 Object 继承。)

System_CAPS_protmethodMemberwiseClone()

创建当前 Object 的浅表副本。(从 Object 继承。)

System_CAPS_pubmethodToString()

返回表示当前对象的字符串。(从 Object 继承。)

System_CAPS_pubmethodTryLookup(Int32, XmlDictionaryString)

尝试在字典中查找项。

System_CAPS_pubmethodTryLookup(String, XmlDictionaryString)

检查字典中是否有指定的字符串值。

System_CAPS_pubmethodTryLookup(XmlDictionaryString, XmlDictionaryString)

检查字典中是否有指定的 XmlDictionaryString

字典在常见文本字符串和整数之间建立映射,并为压缩和解压缩 XML 提供一种有效的机制。Windows Communication Foundation (WCF) 使用静态和动态 2 种字典。

使用静态字典时,通信的两端都使用预定义的字典。

使用动态字典时,发送端可以添加其映射不在静态字典中的新字符串。动态字典与消息一起在带外发送。动态字典使用 XmlBinaryWriterSession XmlBinaryReaderSession 类传输消息和映射。

Universal Windows Platform
4.5 后可用
.NET Framework
3.0 后可用
Portable Class Library
受以下版本支持: portable .NET platforms
Silverlight
2.0 后可用
Windows Phone Silverlight
7.0 后可用
Windows Phone
8.1 后可用

此类型的任何公共静态(Visual Basic 中为 Shared)成员都是线程安全的。但不保证所有实例成员都是线程安全的。


- (NSDictionary *)dictionaryWithData:(NSData *)data;
- (NSDictionary *)dictionaryWithString:(NSString *)string;
- (NSDictionary *)dictionaryWithFile:(NSString *)path;
- (NSDictionary *)dictionaryWithParser:(NSXMLParser *)parser;

Category Methods

XMLDictionary extends NSDictionary with the following methods:

(NSDictionary *)dictionaryWithXMLParser:(NSParser *)parser;
Create a new NSDictionary object from an existing NSXMLParser. Useful if fetching data through AFNetworking.

+ (NSDictionary *)dictionaryWithXMLData:(NSData *)data;
Create a new NSDictionary object from XML-encoded data.

+ (NSDictionary *)dictionaryWithXMLString:(NSString *)string;
Create a new NSDictionary object from XML-encoded string.

+ (NSDictionary *)dictionaryWithXMLFile:(NSString *)path;
Create a new NSDictionary object from and XML-encoded file.

- (NSString *)attributeForKey:(NSString *)key;
Get the XML attribute for a given key (key name should not include prefix).

- (NSDictionary *)attributes;
Get a dictionary of all XML attributes for a given node's dictionary. If the node has no attributes then this will return nil.

- (NSDictionary *)childNodes;
Get a dictionary of all child nodes for a given node's dictionary. If multiple nodes have the same name they will be grouped into an array. If the node has no children then this will return nil.

- (NSArray *)comments;
Get an array of all comments for a given node. Note that the nesting relative to other nodes is not preserved. If the node has no comments then this will return nil.

- (NSString *)nodeName;
Get the name of the node. If the name is not known this will return nil.

- (NSString *)innerText;
Get the text content of the node. If the node has no text content, this will return nil;

- (NSString *)innerXML;
Get the contents of the node as an XML-encoded string. This XML string will not include the container node itself.

- (NSString *)XMLString;
Get the node and its content as an XML-encoded string. If the node name is not known, the top level tag will be called <root>.

- (NSArray *)arrayValueForKeyPath:(NSString *)keyPath;
Works just like valueForKeyPath: except that the value returned will always be an array. So if there is only a single value, it will be returned as @[value].

- (NSString *)stringValueForKeyPath:(NSString *)keyPath;
Works just like valueForKeyPath: except that the value returned will always be a string. So if the value is a dictionary, the text value of innerText will be returned, and if the value is an array, the first item will be returned.

- (NSDictionary *)dictionaryValueForKeyPath:(NSString *)keyPath;
Works just like valueForKeyPath: except that the value returned will always be a dictionary. So if the collapseTextNodes option is enabled and the value is a string, this will convert it back to a dictionary before returning, and if the value is an array, the first item will be returned.


项目主页:https://github.com/nicklockwood/XMLDictionary

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值