HTML code to JSON with help of php -
Hope you can help me solve a small problem.
I saw this post but still found some errors: I created a PHP file that brings a post from WordPress with this format < / P> What I am trying to achieve is that the json object looks like this: Let me call this later angular module Is there a solution to this? Any celebration? Many thanks! / P> Once you convert the document to XML, you can convert it to an array as an array You can do a hierarchy on all elements and simple XML gives you the ability to treat elements in the form of arrays. After separation of information, use json_encode () to create your JSON object An easy way to import HTML code below is to: alternative form From, you have some such libraries and frameworks that do this for you to see it for more information.
& lt; H1 & gt; & Lt; Img src = "category1.jpg" /> Category 1 & lt; / H1> & Lt; Ul & gt; & Lt; Li & gt; Some text & Lt; Strong & gt; & Lt; Em> AUTHOR 1 & lt; / Em> & Lt; / Strong & gt; & Lt; / Li & gt; & Lt; Li & gt; Some other text. & Lt; Strong & gt; & Lt; Em> AUTHOR 2 & lt; / Em> & Lt; / Strong & gt; & Lt; / Li & gt; & Lt; Li & gt; Some other articles. & Lt; Strong & gt; & Lt; Em> AUTHOR 3 & lt; / Em> & Lt; / Strong & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; H1 & gt; & Lt; Img src = "category2.jpg" /> Category 2 & lt; / H1> & Lt; Ul & gt; & Lt; Li & gt; Some new text & Lt; Strong & gt; & Lt; Em> AUTHOR 4 & lt; / Em> & Lt; / Strong & gt; & Lt; / Li & gt; & Lt; Li & gt; Some other new lessons & Lt; Strong & gt; & Lt; Em> AUTHOR 5 & lt; / Em> & Lt; / Strong & gt; & Lt; / Li & gt; & Lt; Li & gt; Some other new lessons & Lt; Strong & gt; & Lt; Em> AUTHOR 6 & lt; / Em> & Lt; / Strong & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
[[Category: "Category 1", content: [{Text: some text ", Author:" Author 1 "}, {Text:" Some other text. ", Author:" author2 "}, {text:" some other text. ", Author:" Author 3 "},]}, {Category:" Category 2 ", Content: [[Lesson:" Some New Text. ", Author:" Writer 4 "}, {Text:" Some Other New Lessons ", Author:" Author 5 "}, {Text:" Some Other Other New Lessons. ", Author:" Author 6 "},]}
$ doc = new DOMDocument (); if (! $ Doc-> Load HTML ($ html)) // Page $ page = must be html code from simplexml_import_dom ($ doc); // $ something with page
Comments
Post a Comment