NSXMLDocument不具有<?XML版本= “1.0” 编码= “UTF-8” 独立= “否”?>在可可触摸
问题描述:
创建XML文件成功的,但它不包含第一行:NSXMLDocument不具有<?XML版本= “1.0” 编码= “UTF-8” 独立= “否”?>在可可触摸
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
此代码是:
xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:url options:NSXMLDocumentTidyXML error:&error];
if(xmlDoc)
{
root = [xmlDoc rootElement];
}
else
{
root = [NSXMLNode elementWithName: @"P2Main"];
[root addAttribute:[NSXMLNode attributeWithName:@"xmlns:xsi" stringValue:@"http://www.w3.org/2001/XMLSchema-instance"]];
[root addAttribute:[NSXMLNode attributeWithName:@"xmlns" stringValue:@"urn:schemas-Professional-Plug-in:P2:ClipMetadata:v3.1"]];
xmlDoc = [[NSXMLDocument alloc] initWithRootElement:root];
}
我不知道为什么?你有什么建议吗?在此先感谢
答
也许你应该尝试使用下一个方法来设置此数据:
setCharacterEncoding:
setStandalone:
setVersion:
详见
感谢它的工作原理 – HTKT611