たとえば、画面にボタンがあり、xml タグが
mynode attribute1="" attribute2="" attribute3="" /mynode
attribute3 の初期値が NO の場合、ボタンをタップすると YES に変更され、プロジェクト ディレクトリにある xml ファイルに書き込まれます。誰かがこれについて知っているなら、私を助けてください。GDataXML の addattribute メソッドを使用してみましたが、タグを変更できません。
たとえば、画面にボタンがあり、xml タグが
mynode attribute1="" attribute2="" attribute3="" /mynode
attribute3 の初期値が NO の場合、ボタンをタップすると YES に変更され、プロジェクト ディレクトリにある xml ファイルに書き込まれます。誰かがこれについて知っているなら、私を助けてください。GDataXML の addattribute メソッドを使用してみましたが、タグを変更できません。
It is not possible to edit the XML file in Objective - c. If you want to do this, then you needs to create your own xml file or you can append the tags to the existing xml. Please refer the following code where I am created my own xml to append the bytes array of a image & adding it to the original xml.
//Encode all the data and get the XML string
NSString *theXML = [[NSString alloc]
initWithBytes: [clipSvgData bytes]
length:[clipSvgData length]
encoding:NSUTF8StringEncoding];
//Returns the substring of an main xml file by excluding the extra xml tags
NSString *startTag = @"<svg";
NSString *endTag = @"</svg>";
NSString *responseString;
NSScanner *scanner = [[NSScanner alloc] initWithString:theXML];
[scanner scanUpToString:startTag intoString:nil];
scanner.scanLocation += [startTag length];
[scanner scanUpToString:endTag intoString:&responseString];
[scanner release];
//Remove the SVG tag from main xml
NSString *startTag1 = @">";
NSString *endTag1 = @"</svg>";
NSString *responseString1;
NSScanner *scanner1 = [[NSScanner alloc] initWithString:[NSString stringWithFormat:@"<svg %@ </svg>",responseString]];
[scanner1 scanUpToString:startTag1 intoString:nil];
scanner1.scanLocation += [startTag1 length];
[scanner1 scanUpToString:endTag1 intoString:&responseString1];
[scanner1 release];
NSString *strSVGNode = [NSString stringWithFormat:@"<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"%fpx\" y=\"%fpx\" width=\"%fpx\" height=\"%fpx\" viewBox=\"0 0 141.73 141.73\" enable-background=\"new 0 0 141.73 141.73\" xml:space=\"preserve\" preserveAspectRatio=\"none\">", imgXPos, imgYPos, imgWidth, imgHeight];
NSString *strClipXml = [NSString stringWithFormat:@"%@ %@ </svg></g>",strSVGNode ,responseString1];
//Add the created SVG as new node in main SVG file.
GDataXMLNode *clipNode = [GDataXMLNode textWithStringValue:[NSString stringWithFormat:@"%@",strClipXml]];
[xmlDocument.rootElement addChild:clipNode];
You can modify it as per your requirement.