Let me try this again. I am copying some nodes from an FCP project XML structure to a new XML structure. This was all working fine until I got to a pathurl node, copied it and tried to make that copy a child of a file node.
Here are the file and pathurl nodes:
// New file node
NSXMLElement *fileElement = [NSXMLElement elementWithName:@"file"];
// firstPathurlXmlElement comes from a query on the project XML
NSLog(@"%@", firstPathurlXmlElement) gives:
<pathurl>file://localhost/Users/username/FCP Beyond Files/Broken Fists_multicam/A_16_A-1</pathurl>
The following code leads to an error when I look at the result with NSLog:
NSXMLElement *pathurlElement = [firstPathurlXmlElement copy];
[fileElement addChild:pathurlElement];
NSLog(@"%@", fileElement) => *** -[NSMethodSignature appendCharacters:length:]: unrecognized selector sent to instance 0x16a69e90
But this code, which should be pretty much equivalent, works:
firstPathurlXmlString = [firstPathurlXmlElement stringValue];
NSXMLElement *pathurlElement = [[NSXMLElement alloc] initWithName:@"pathurl" stringValue:firstPathurlXmlString];
[fileElement addChild:pathurlElement];
NSLog(@"%@", fileElement) => <file><pathurl>file://localhost/Users/username/FCP Beyond Files/Broken Fists_multicam/A_16_A-1</pathurl></file>
Using the first method is a workaround, but I'd like to understand why the second method doesn't work.
Bruce
On Mon, Aug 18, 2008 at 2:38 PM, Bruce Sharpe
<email@hidden> wrote:
Hi Helena,
No, the problem is that [firstPathurlXmlNode
stringValue] is not returning what I expect.
However, I can't reproduce the behavior in a simple standalone example, so my problem must be elsewhere. So you can ignore my previous message until I can pin it down.
Thanks,
BruceOn Mon, Aug 18, 2008 at 1:24 PM, Helena Ju
<email@hidden> wrote:
Hey Bruce!
I'm not exactly sure I understand the question but I think the goal to get a string back from the pathurl node without any of the %-escaped entities.
Here's a snippet of code that may help (NS first, then CF-equivalents)
//if you get the node (firstPathurlXmlNode):
//you can get the string value of that node, and make a NSURL with it:
NSString* firstPathString = [firstPathurlXmlNode stringValue];
NSURL * mediaurl = [NSURL URLWithString: firstPathString];
//you can remove the %-escaping:
NSString* non_escapedPath = [firstPathString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//=============
//you can get the string value of that node, and make a NSURL with it:
CFStringRef cfFirstPathString = CFXMLNodeGetString(firstPathurlXmlNode);
CFURLRef cfMediaurl = CFURLCreateWithString(kCFAllocatorDefault, cfFirstPathString, NULL);
//you can remove the %-escaping:
CFStringRef cfNon_escapedPath = CFURLCreateStringByReplacingPercentEscapes(kCFAllocatorDefault, cfFirstPathString, CFSTR(""));
Please let me know if the question was something else, and I'll see if I can help.
Cheers!
Helena
On Aug 18, 2008, at 12:16 PM, Bruce Sharpe wrote:
I am running into a conflict between URL encoding and XML node values.
I retrieve my project as XML. It has nodes like this:
<pathurl>
file://localhost/Broken Fists/clip1</pathurl>
where the space in "Broken Fists" is URL encoded as .
If I try to represent that node as a string via stringValue or XMLString it comes out as
<pathurl>
file://localhost/Broken 0.000000ists/clip1</pathurl>
apparently because it interpreted F as a C string format code.
This is messing me up because NSLog and other functions report errors like
[NSMethodSignature appendCharacters:length:]: unrecognized selector sent to instance 0x16b416b0
Am I doing something wrong, or is there a workaround?
Bruce
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: