O-MI-Node/html/example/example.js
/**
 * Parses XML to JSON string (brute force)
 * NOTE: Function was created to follow the O-MI schema, and the vtt/otaakari4 structure in mursu
 * @oaram {string} xml The xml string
 * @param {Number} buildingDepth The depth of the building Object in Objects tree
 * @returns {string} the JSON string
 */
Parses XML to JSON string (brute force)
NOTE: Function was created to follow the O-MI schema, and the vtt/otaakari4 structure in mursu
@oaram {string} xml The xml string
@param {Number} buildingDepth The depth of the building Object in Objects tree
@returns {string} the JSON string
Parses XML to JSON string ( brute force ) NOTE : Function was created to follow the O - MI schema and the vtt / otaakari4 structure in mursu @oaram { string } xml The xml string @param { Number } buildingDepth The depth of the building Object in Objects tree @returns { string } the JSON string
function parseToJson(xml, buildingDepth){
        var xmlDoc = $.parseXML(xml);
        var str = '[';
        $(xmlDoc).find('Objects > Object > Object').each(function(){
                var count = 0;
                $(this).each(function(){
                        $($(this).find("Object")).each(function(){
                                if(count === 0){
                                        str += '{';
                                } else {
                                        str += ',{';
                                }
                                str += '"building":"' + $($(this).parent().find("id")[0]).text() + '"';
                                str += ', "roomID":"' + $(this).find("id").text() + '"';
                                str += ', "type":"' + $(this).find('InfoItem').attr('name') + '"';
                                str += ', "value":"' + $(this).find('value').text() + '"';
                                str += '}';
                                count += 1;
                        });
                });
        });
        str += ']';
        return str;
}
function parseToJson ( xml , buildingDepth ) { var xmlDoc = $ . parseXML ( xml ) ; var str = '[' ; $ ( xmlDoc ) . find ( 'Objects > Object > Object' ) . each ( function ( ) { var count = 0 ; $ ( this ) . each ( function ( ) { $ ( $ ( this ) . find ( "Object" ) ) . each ( function ( ) { if ( count === 0 ) { str += '{' ; } else { str += ',{' ; } str += '"building":"' + $ ( $ ( this ) . parent ( ) . find ( "id" ) [ 0 ] ) . text ( ) + '"' ; str += ', "roomID":"' + $ ( this ) . find ( "id" ) . text ( ) + '"' ; str += ', "type":"' + $ ( this ) . find ( 'InfoItem' ) . attr ( 'name' ) + '"' ; str += ', "value":"' + $ ( this ) . find ( 'value' ) . text ( ) + '"' ; str += '}' ; count += 1 ; } ) ; } ) ; } ) ; str += ']' ; return str ; }
Parses XML to JSON string (brute force)
 NOTE: Function was created to follow the O-MI schema, and the vtt/otaakari4 structure in mursu
 @oaram {string} xml The xml string
 @param {Number} buildingDepth The depth of the building Object in Objects tree
 @returns {string} the JSON string
Parses XML to JSON string ( brute force ) NOTE : Function was created to follow the O - MI schema and the vtt / otaakari4 structure in mursu @oaram { string } xml The xml string @param { Number } buildingDepth The depth of the building Object in Objects tree @returns { string } the JSON string