Parse XML with jQuery – Education Career Blog

I would need to parse this:

<?xml version="1.0" encoding="utf-8"?>
<blamatrixrix>
<name></name>
<columns number="2">
 <column id="title" num="0">Title</column>
 <column id="content" num="1">Content</column>
</columns>
<rows number="7"></rows>
<b>Description</c>
<bDescription text here</b>
<b>Some title 1</b>
<b>Some text blabla for Some title 1</b>
<b>Some title 2</b>
<b>Some text blabla for Some title 2</b>
<b>Some title 3</b>
<b>Some text blabla for Some title 3</b>
<b>Some title 4</b>
<b>Some text blabla for Some title 4</b>
<b>Some title 5</b>
<b>Some text blabla for Some title 5</b>
<b>Some title 6</b>
<b>Some text blabla for Some title 6</b>
</blamatrixrix>

In a way that the content is in a table. And ‘Some titles’ are in own and ‘Some texts’ in own .

Because the content is inside those is giving me trouble. Should I use regex somehow or?

I get that xml from this:

$.getJSON(JSONquery, function(data){
   $.each(data, function(i,item){

EDIT:

@ Liam Bailey

Here is the code output of that JSONquery:

 {"name":"139930 blablabla","id":599,"contentobject_id":599,"main_node_id":565,"modified":"1287146683","published":"1264417592","section_id":1,"current_language":"eng","owner_id":193,"class_id":28,"class_name":"Product","class_identifier":"product","is_container":0,"node_id":565,"parent_node_id":355,"url_alias":"Products\/blablabla\/blablabla\/139930-blablabla","depth":6,"path":false,"children_count":false,"image_attributes":"main_image","listing_thumbnail","promo_badge","data_map":{"title":{"id":"6488","type":"ezstring","identifier":"title","content":"blablabla"},"short_title":{"id":"6489","type":"ezstring","identifier":"short_title","content":"139930 blablabla"},"subtitle":{"id":"6490","type":"ezstring","identifier":"subtitle","content":""},"authors":{"id":"6491","type":"ezauthor","identifier":"authors","content":"blablabla blablabla | [email protected] blablabla .com|0"},"keywords":{"id":"6492","type":"ezkeyword","identifier":"keywords","content":"blablabla"},"item_id":{"id":"6493","type":"ezstring","identifier":"item_id","content":"139930"},"price":{"id":"6494","type":"ezprice","identifier":"price","content":"0|1|1"},"is_shoppable":{"id":"6495","type":"ezboolean","identifier":"is_shoppable","content":"0"},"main_image":{"id":"6496","type":"ezimage","identifier":"main_image","content":{"reference":false,"small":{"name":"small","width":"100","height":"33","mime_type":"image\/jpeg","filename":"139930-blablabla_small.jpg","suffix":"jpg","dirpath":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/lawn-blablabla\/blablabla\/139930-blablabla\/6496-25-eng-EU","alias_key":"2343348577","timestamp":"1286700665","is_valid":"1","url":"var\/blablabla\/storage\/images\/frontpage\/products\/blablabla-care\/blablabla\/139930-blablabla/6496-25-eng-EU\/139930-blablabla-blablablar_small.jpg","basename":"139930-blablabla-blablablar","alternative_text":"","text":"","original_filename":"139930_2.jpg","full_path":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/blab-bla\/blaaders\/139930-blablabla-blablablar\/6496-25-eng-EU\/139930-blablabla-blablablar_small.jpg","is_new":false,"info":{"Height":"200","Width":"600","IsColor":"1"}},"tiny":false,"medium":false,"large":false,"rss":false,"width100":false,"width150":false,"width200":false,"width300":false,"width400":false,"product_main":false,"product_main_large":false,"product_listing":false,"product_category_listing":false,"product_media_listing":false,"rc_full":false,"main_banner":false,"main_banner_front":false,"promo_badge":false,"multiuploadthumbnail":false,"original":{"url":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/blab-bla\/blaaders\/139930-blablabla-blablablar\/6496-25-eng-EU\/139930-blablabla-blablablar.jpg|"}}},"listing_thumbnail":{"id":"6497","type":"ezimage","identifier":"listing_thumbnail","content":{"reference":false,"small":null,"tiny":false,"medium":false,"large":false,"rss":false,"width100":false,"width150":false,"width200":false,"width300":false,"width400":false,"product_main":false,"product_main_large":false,"product_listing":false,"product_category_listing":false,"product_media_listing":false,"rc_full":false,"main_banner":false,"main_banner_front":false,"promo_badge":false,"multiuploadthumbnail":false,"original":{"url":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/blab-bla\/blaaders\/139930-blablabla-blablablar\/6497-25-eng-EU\/139930-blablabla-blablablar.jpg|"}}},"related_images":{"id":"6498","type":"ezobjectrelationbrowse","identifier":"related_images","content":"605"},"related_media":{"id":"6499","type":"ezobjectrelationbrowse","identifier":"related_media","content":""},"related_products":{"id":"6500","type":"ezobjectrelationbrowse","identifier":"related_products","content":""},"related_faq_items":{"id":"6501","type":"ezobjectrelationbrowse","identifier":"related_faq_items","content":""},"awards":{"id":"6502","type":"ezxmltext","identifier":"awards","content":"\n
            \n"},"country_awards":{"id":"601924","type":"ezxmltext","identifier":"country_awards","content":"\n


        \n"},"description":{"id":"6503","type":"ezxmltext","identifier":"description","content":"\n
            blablabla<\/line><\/paragraph><\/section>\n"},"features":{"id":"6504","type":"ezxmltext","identifier":"features","content":"\n
             • blablabla <\/paragraph><\/li>
             • blablabla <\/paragraph><\/li>
             • blablabla <\/paragraph><\/li>
             • blablabla <\/paragraph><\/li>
             • C blablabla <\/paragraph><\/li><\/ul><\/paragraph><\/section>\n"},"freeform_1_title":{"id":"6505","type":"ezstring","identifier":"freeform_1_title","content":""},"freeform_1_content":{"id":"6506","type":"ezxmltext","identifier":"freeform_1_content","content":"\n\n"},"freeform_2_title":{"id":"6507","type":"ezstring","identifier":"freeform_2_title","content":""},"freeform_2_content":{"id":"6508","type":"ezxmltext","identifier":"freeform_2_content","content":"\n\n"},"freeform_3_title":{"id":"6509","type":"ezstring","identifier":"freeform_3_title","content":""},"freeform_3_content":{"id":"6510","type":"ezxmltext","identifier":"freeform_3_content","content":"\n\n"},"promo_badge":{"id":"277833","type":"ezimage","identifier":"promo_badge","content":{"reference":false,"small":null,"tiny":false,"medium":false,"large":false,"rss":false,"width100":false,"width150":false,"width200":false,"width300":false,"width400":false,"product_main":false,"product_main_large":false,"product_listing":false,"product_category_listing":false,"product_media_listing":false,"rc_full":false,"main_banner":false,"main_banner_front":false,"promo_badge":false,"multiuploadthumbnail":false,"original":{"url":"|"}}},"weight":{"id":"433850","type":"ezstring","identifier":"weight","content":"1052"},"length":{"id":"433851","type":"ezstring","identifier":"length","content":"970"},"product_attributes":{"id":"691877","type":"blamatrix","identifier":"product_attributes","content":{"HTTPValue":null,"Content":null,"DisplayInfo":null,"IsValid":null,"ContentClassAttributeID":"891","ValidationError":null,"ValidationLog":null,"ContentClassAttributeIdentifier":"product_attributes","ContentClassAttributeCanTranslate":null,"ContentClassAttributeName":null,"ContentClassAttributeIsInformationCollector":null,"ContentClassAttributeIsRequired":null,"PersistentDataDirty":false,"InputParameters":false,"HasValidationError":false,"DataTypeCustom":null,"ID":"691877","ContentObjectID":"599","Version":"26","LanguageCode":"eng-EU","LanguageID":"8","AttributeOriginalID":"0","SortKeyInt":"0","SortKeyString":"","DataTypeString":"blamatrix","DataText":"\n<\/name>Title<\/column>Content<\/column><\/columns>Description<\/b><ul><li>I NEED THIS DESC TEXT<\/li><\/ul><\/b>SOME TITLE<\/b><ul><li>THIS TEXT<\/li><\/ul><\/b>THIS TITLE<\/b>THIS TEXT<\/b>THIS TITLE<\/b>AGAIN THIS TEXT<\/b>THIS TITLE<\/b><ul><li>THIS TEXAT<\/li><\/ul><\/b>THIS TITLE<\/b><ul><li>THIS TEXT<\/li><\/ul><\/b>YEP THIS TITLE<\/b>THIS<\/b><\/blamatrix>\n","DataInt":null,"DataFloat":"0"}}}}

,

@ Liam Bailey

Here is the code output of that JSONquery:

{"name":"139930 blablabla","id":599,"contentobject_id":599,"main_node_id":565,"modified":"1287146683","published":"1264417592","section_id":1,"current_language":"eng","owner_id":193,"class_id":28,"class_name":"Product","class_identifier":"product","is_container":0,"node_id":565,"parent_node_id":355,"url_alias":"Products\/blablabla\/blablabla\/139930-blablabla","depth":6,"path":false,"children_count":false,"image_attributes":"main_image","listing_thumbnail","promo_badge","data_map":{"title":{"id":"6488","type":"ezstring","identifier":"title","content":"blablabla"},"short_title":{"id":"6489","type":"ezstring","identifier":"short_title","content":"139930 blablabla"},"subtitle":{"id":"6490","type":"ezstring","identifier":"subtitle","content":""},"authors":{"id":"6491","type":"ezauthor","identifier":"authors","content":"blablabla blablabla | [email protected] blablabla .com|0"},"keywords":{"id":"6492","type":"ezkeyword","identifier":"keywords","content":"blablabla"},"item_id":{"id":"6493","type":"ezstring","identifier":"item_id","content":"139930"},"price":{"id":"6494","type":"ezprice","identifier":"price","content":"0|1|1"},"is_shoppable":{"id":"6495","type":"ezboolean","identifier":"is_shoppable","content":"0"},"main_image":{"id":"6496","type":"ezimage","identifier":"main_image","content":{"reference":false,"small":{"name":"small","width":"100","height":"33","mime_type":"image\/jpeg","filename":"139930-blablabla_small.jpg","suffix":"jpg","dirpath":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/lawn-blablabla\/blablabla\/139930-blablabla\/6496-25-eng-EU","alias_key":"2343348577","timestamp":"1286700665","is_valid":"1","url":"var\/blablabla\/storage\/images\/frontpage\/products\/blablabla-care\/blablabla\/139930-blablabla/6496-25-eng-EU\/139930-blablabla-blablablar_small.jpg","basename":"139930-blablabla-blablablar","alternative_text":"","text":"","original_filename":"139930_2.jpg","full_path":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/blab-bla\/blaaders\/139930-blablabla-blablablar\/6496-25-eng-EU\/139930-blablabla-blablablar_small.jpg","is_new":false,"info":{"Height":"200","Width":"600","IsColor":"1"}},"tiny":false,"medium":false,"large":false,"rss":false,"width100":false,"width150":false,"width200":false,"width300":false,"width400":false,"product_main":false,"product_main_large":false,"product_listing":false,"product_category_listing":false,"product_media_listing":false,"rc_full":false,"main_banner":false,"main_banner_front":false,"promo_badge":false,"multiuploadthumbnail":false,"original":{"url":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/blab-bla\/blaaders\/139930-blablabla-blablablar\/6496-25-eng-EU\/139930-blablabla-blablablar.jpg|"}}},"listing_thumbnail":{"id":"6497","type":"ezimage","identifier":"listing_thumbnail","content":{"reference":false,"small":null,"tiny":false,"medium":false,"large":false,"rss":false,"width100":false,"width150":false,"width200":false,"width300":false,"width400":false,"product_main":false,"product_main_large":false,"product_listing":false,"product_category_listing":false,"product_media_listing":false,"rc_full":false,"main_banner":false,"main_banner_front":false,"promo_badge":false,"multiuploadthumbnail":false,"original":{"url":"var\/blablabal_blablabal\/storage\/images\/frontpage\/products\/blab-bla\/blaaders\/139930-blablabla-blablablar\/6497-25-eng-EU\/139930-blablabla-blablablar.jpg|"}}},"related_images":{"id":"6498","type":"ezobjectrelationbrowse","identifier":"related_images","content":"605"},"related_media":{"id":"6499","type":"ezobjectrelationbrowse","identifier":"related_media","content":""},"related_products":{"id":"6500","type":"ezobjectrelationbrowse","identifier":"related_products","content":""},"related_faq_items":{"id":"6501","type":"ezobjectrelationbrowse","identifier":"related_faq_items","content":""},"awards":{"id":"6502","type":"ezxmltext","identifier":"awards","content":"\n
        \n"},"country_awards":{"id":"601924","type":"ezxmltext","identifier":"country_awards","content":"\n


    \n"},"description":{"id":"6503","type":"ezxmltext","identifier":"description","content":"\n
        blablabla<\/line><\/paragraph><\/section>\n"},"features":{"id":"6504","type":"ezxmltext","identifier":"features","content":"\n
         • blablabla <\/paragraph><\/li>
         • blablabla <\/paragraph><\/li>
         • blablabla <\/paragraph><\/li>
         • blablabla <\/paragraph><\/li>
         • C blablabla <\/paragraph><\/li><\/ul><\/paragraph><\/section>\n"},"freeform_1_title":{"id":"6505","type":"ezstring","identifier":"freeform_1_title","content":""},"freeform_1_content":{"id":"6506","type":"ezxmltext","identifier":"freeform_1_content","content":"\n\n"},"freeform_2_title":{"id":"6507","type":"ezstring","identifier":"freeform_2_title","content":""},"freeform_2_content":{"id":"6508","type":"ezxmltext","identifier":"freeform_2_content","content":"\n\n"},"freeform_3_title":{"id":"6509","type":"ezstring","identifier":"freeform_3_title","content":""},"freeform_3_content":{"id":"6510","type":"ezxmltext","identifier":"freeform_3_content","content":"\n\n"},"promo_badge":{"id":"277833","type":"ezimage","identifier":"promo_badge","content":{"reference":false,"small":null,"tiny":false,"medium":false,"large":false,"rss":false,"width100":false,"width150":false,"width200":false,"width300":false,"width400":false,"product_main":false,"product_main_large":false,"product_listing":false,"product_category_listing":false,"product_media_listing":false,"rc_full":false,"main_banner":false,"main_banner_front":false,"promo_badge":false,"multiuploadthumbnail":false,"original":{"url":"|"}}},"weight":{"id":"433850","type":"ezstring","identifier":"weight","content":"1052"},"length":{"id":"433851","type":"ezstring","identifier":"length","content":"970"},"product_attributes":{"id":"691877","type":"blamatrix","identifier":"product_attributes","content":{"HTTPValue":null,"Content":null,"DisplayInfo":null,"IsValid":null,"ContentClassAttributeID":"891","ValidationError":null,"ValidationLog":null,"ContentClassAttributeIdentifier":"product_attributes","ContentClassAttributeCanTranslate":null,"ContentClassAttributeName":null,"ContentClassAttributeIsInformationCollector":null,"ContentClassAttributeIsRequired":null,"PersistentDataDirty":false,"InputParameters":false,"HasValidationError":false,"DataTypeCustom":null,"ID":"691877","ContentObjectID":"599","Version":"26","LanguageCode":"eng-EU","LanguageID":"8","AttributeOriginalID":"0","SortKeyInt":"0","SortKeyString":"","DataTypeString":"blamatrix","DataText":"\n<\/name>Title<\/column>Content<\/column><\/columns>Description<\/b><ul><li>I NEED THIS DESC TEXT<\/li><\/ul><\/b>SOME TITLE<\/b><ul><li>THIS TEXT<\/li><\/ul><\/b>THIS TITLE<\/b>THIS TEXT<\/b>THIS TITLE<\/b>AGAIN THIS TEXT<\/b>THIS TITLE<\/b><ul><li>THIS TEXAT<\/li><\/ul><\/b>THIS TITLE<\/b><ul><li>THIS TEXT<\/li><\/ul><\/b>YEP THIS TITLE<\/b>THIS<\/b><\/blamatrix>\n","DataInt":null,"DataFloat":"0"}}}}

Leave a Comment