Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing and iOS plist file #87

Open
mcferren opened this issue Apr 18, 2014 · 1 comment
Open

Parsing and iOS plist file #87

mcferren opened this issue Apr 18, 2014 · 1 comment

Comments

@mcferren
Copy link

Hi there,

I am attempting to use xmldom to parse an iOS plist file that I plan to use for localization purposes in my javascript app. My end result will concatenate key / value tuples from multiple source (plist) files so that I have one master language file for my javascript app. Here is an example of how these source plist files are formatted:

CancelTitle
Cancel
EmailLabel
Email

To do so, I am trying to build a grunt task that will read the source file(s) and interpret it(them) as xml. In my Gruntfile.js, I have this under the grunt.initConfig block:

    translator: {
        options: {
          sourceFile: 'app/config/translations/original.plist'
        }
    }

Down below I register a task with this code:

grunt.registerTask('translate', [
    'translator'
]);

Inside of of the task directory file, I have this code:

module.exports = function (grunt) {

var xmldom = require('xmldom'),
    xpath = require('xpath'),
    _ = require('lodash'),
    ATTRIBUTE_NODE = 2;


grunt.registerMultiTask('translator', 'Updates values in XML files based on XPath queries', function () {

    var options = this.options();
    var sourceFile = options.sourceFile;
    var src =  grunt.file.read(sourceFile);
    var domParser = new xmldom.DOMParser();
    var doc = domParser.parseFromString(
            src
            ,'text/xml');
    var dictNode = xmlContent.getElementsByTagName('dict')[0];
    console.log(dictNode);
    ...

I am in the beginning stages of this project now and I am just trying to read the source file and interpret it as xml. After running grunt translate, I am receiving this error in the console:

end tag name: string is not match the current start tagName:dict
@#[line:3225,col:43]

Nothing comes up when I google for the this string however, I was able to spend some time snooping in the source code and found this line inside the sax.js file on line 105:

if(config.tagName != tagName){
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
}

https://github.com/jindw/xmldom/blob/c033b1907c049ee10a9cc71133925480f03e7134/sax.js

I would be very grateful for any help you could provide on the matter.

All the best,

Ben

@mcferren
Copy link
Author

this seems to be what I've been looking for: https://github.com/jacobbudin/plist-parser

apologies for taking up space

hope this helps those who come across this post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant