Skip to content

Enclosing XML Tag Name Unavailable as Object Name When Unmarshaled #201

@MatthewGitter

Description

@MatthewGitter

Hello. When unmarshalling an XML string, eg. var something = unmarshaller.unmarshalString('<thing>Some text.</thing>'); , the overall enclosing XML tag name, ie. <thing>, is not available in the unmarshalled JS object, ie. thing.value.data is unavailable in the JS script. Instead the overall enclosing XML tag name is replaced by the name of the variable coded in the assignment to the return value of the unmarshaller, ie. something , so the value enclosed by the XML is referenced in the JS script by something.value.data . Unless I'm missing something in the unmarshalling process that preserves the outermost enclosing tag name.

var One = {
    name: 'One',
    typeInfos: [{
        type: 'classInfo',
        localName: 'ValueType',
        propertyInfos: [{
            name: 'data',
            type: 'value',
            typeInfo: 'String'
        }]
    }],
    elementInfos: [{
        elementName: 'thing',
        typeInfo: 'One.ValueType'
    }]
};
var context = new Jsonix.Context([One]);
var unmarshaller = context.createUnmarshaller();
var something = unmarshaller.unmarshalString('<thing>Some text.</thing>');
console.log("something:\n");
console.log(something);
console.log("something data value:");
console.log(something.value.data);

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions