我成功创建了 XML 文件,但它不包含第一行:
<?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];
}
我不知道为什么?你有什么建议吗?提前致谢