ich einige Probleme habe die folgende XML-Daten-Analyse:Objective C - Parsen von XML mit Namespace-Pfad verwenden
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<encryption xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<resource xmlns="http://ns.nuts-for-africa.com/epubdrm">urn:uuid:7297037a-6a5e-4bb1-bfa3-9a683288adb5</resource>
</KeyInfo>
<CipherData>
<CipherReference URI="OPS/epubbooksinfo.html"/>
</CipherData>
</EncryptedData>
<EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<resource xmlns="http://ns.nuts-for-africa.com/epubdrm">urn:uuid:7297037a-6a5e-4bb1-bfa3-9a683288adb5</resource>
</KeyInfo>
<CipherData>
<CipherReference URI="OPS/chapter-008.html"/>
</CipherData>
</EncryptedData>
ich den folgenden Code verwende die die XML-Datei lesen und analysieren. Ich habe jede XPath Kombination habe ich versucht, aus denken konnte, konnte aber nicht bekommen, damit es funktioniert:
NSData *encryptData = [self getResourceFileName:filename extension:fileext readFileInZip:@"encryption.xml"]; //this is a function to retrieve files from a zip file. This is working
if(encryptData != nil){
//http://www.w3.org/2001/04/xmlenc#
CXMLDocument* cryptFile = [[CXMLDocument alloc] initWithData:encryptData options:0 error:nil];
NSArray *encryptionItems = [cryptFile nodesForXPath:@"EncryptedData" namespaceMappings:[NSDictionary dictionaryWithObject:@"http://www.w3.org/2001/04/xmlenc#" forKey:@""] error:nil];
for (CXMLElement* encEl in encryptionItems) {
NSArray *uuidArray = [encEl nodesForXPath:@"KeyInfo/resource" namespaceMappings:nil error:nil];
NSString *uuid = [[uuidArray objectAtIndex:0] stringValue];
NSArray *fileArray = [encEl nodesForXPath:@"CipherData/CipherReference" namespaceMappings:nil error:nil];
NSString *fileRef = [[fileArray objectAtIndex:0] stringValue];
NSLog(@"File: %@ - UUID: %@",fileRef,uuid);
}
}
Es tut mir sehr leid, aber ich bin verpflichtet, Pfad und CXMLDocuments und CXMLElements zu verwenden – EZFrag