2015-10-20 37 views
1

你好我使用XmlDocument的更新plist中,當我保存它看起來像這樣<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" []>錯誤[]在XmlDocument的類型

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

打算結束這是我的代碼

UpdatePlist .FS:

namespace TestPlist 

open System 
open System.Xml 


module UpdatePlist = 
    type PlistLocation = PlistLocation of string 
    type Version = Version of string 

    let updatePlist (PlistLocation(plist), Version(stable), Version(revision), Version(last)) = 
    let mydocument = new XmlDocument() 
    mydocument.Load(plist) 
    mydocument.PreserveWhitespace |> ignore 
    let PlistNodes = mydocument.SelectNodes("descendant::key") 
    let version = stable + "." + revision + "." + last 
    PlistNodes.Item(8).NextSibling.InnerText <- version 
    mydocument.Save(plist) 
    "done" 

和Program.fs:

namespace TestPlist 
open UpdatePlist 
module Main= 
    [<EntryPoint>] 
    let main argv = 
     updatePlist(PlistLocation("../../Info.plist"), Version("8"), Version("5"), Version("9")) 
     |> printfn "%A" 

而且plist文件的Info.plist:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
<dict> 
    <key>UIDeviceFamily</key> 
    <array> 
    <integer>1</integer> 
    <integer>2</integer> 
    </array> 
    <key>CFBundleInfoDictionaryVersion</key> 
    <string>6.0</string> 
    <key>CFBundleExecutable</key> 
    <string> 
    </string> 
    <key>UISupportedInterfaceOrientations</key> 
    <array> 
    <string>UIInterfaceOrientationPortrait</string> 
    </array> 
    <key>LSApplicationCategoryType</key> 
    <string> 
    </string> 
    <key>MinimumOSVersion</key> 
    <string>8</string> 
    <key>CFBundleDisplayName</key> 
    <string></string> 
    <key>CFBundleIdentifier</key> 
    <string></string> 
    <key>CFBundleShortVersionString</key> 
    <string>8.5.9</string> 
    <key>CFBundleVersion</key> 
    <string>1</string> 
</dict> 
</plist> 

請幫助!

+0

請修復您的代碼,那麼也許我們可以幫助 – Carsten

+0

修復它,謝謝@Carsten –

+1

我的猜測是,你沒有得到任何幫助你的問題,因爲你讓我們無法重現這個問題。請提供[簡短,獨立,正確(可編譯),示例](http://sscce.org)。 –

回答

1

我找到了答案

let documentTypeWithNullInternalSubset = mydocument.CreateDocumentType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); 
mydocument.ReplaceChild(documentTypeWithNullInternalSubset, mydocument.DocumentType) |> ignore 

全部保存()之前

我發現這個線程, C# LINQ TO XML - Remove "[]" characters from the DTD header 所以這個問題之前就已經存在:/抱歉