+ -
当前位置:首页 → 问答吧 → 求用LINQ to XML查询一非常规xml文件语句

求用LINQ to XML查询一非常规xml文件语句

时间:2011-12-21

来源:互联网

文件内容如下:
XML code


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Product ID</key>
<string>IPHONE_1ND</string>
<key>CFBundleName</key>
<string>AlipayPortal</string>
<key>DTSDKName</key>
<string>iphoneos4.2</string>
<key>DTXcode</key>
<string>0325</string>
<key>UTImportedTypeDeclarations</key>
<array>
</array>
<key>Safepay version</key>
<string>2.2.4</string>
<key>CFBundleDevelopmentRegion</key>
<string>zh_CN</string>
<key>CFBundleVersion</key>
<string>3.1</string>
<key>NSMainNibFile</key>
<string>MainWindow</string>
<key>CFBundleDocumentTypes</key>
<array>
</array>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleIconFile</key>
<string>icon.png</string>
<key>User Agent</key>
<string>ALIPAY_FOR_IOS</string>
<key>DTPlatformName</key>
<string>iphoneos</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>AlipayPortal</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>alipay</string>
</array>
</dict>
</array>
<key>CFBundleIdentifier</key>
<string>com.alipay.iphoneclient</string>
<key>CFBundleResourceSpecification</key>
<string>ResourceRules.plist</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>UTExportedTypeDeclarations</key>
<array>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>CFBundleIconFiles</key>
<array>
<string>icon.png</string>
<string>[email protected]</string>
</array>
<key>CFBundleDisplayName</key>
<string>支付宝</string>
<key>DTXcodeBuild</key>
<string>10M2423</string>
<key>DTPlatformVersion</key>
<string>4.2 Seed 2</string>
<key>MinimumOSVersion</key>
<string>3.0</string>
<key>DTPlatformBuild</key>
<string>8C134</string>
<key>Product Version</key>
<string>3.0.1.1025</string>
</dict>
</plist>


要求一、查询CFBundleDisplayName的值,此例值为“支付宝”
要求二:查询CFBundleIconFiles的值,此例值为icon.png、[email protected]

作者: dreamsme   发布时间: 2011-12-21

C# code

void Main()
{
    XDocument xml=XDocument.Load("c:\\1.xml");
    var query=from x in xml.Descendants("dict") 
              where x.Parent.Name=="plist" 
              from y in x.Elements()
              where y.Value=="CFBundleDisplayName"
              select y.NextNode;
              
    var query1=from x in xml.Descendants("dict") 
              where x.Parent.Name=="plist" 
              from y in x.Elements()
              where y.Value=="CFBundleIconFiles"
              select y.NextNode;
}


作者: q107770540   发布时间: 2011-12-21

相关阅读 更多

热门下载

更多