Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing large XML file with PHP with non-standard nesting of elements (SAP Roadmap File)
    text
    copied!<p><strong>Background of issue:</strong></p> <p>I have a folder with lots of directories, files, attachments, and JavaScript. There is a main core file that is processed by ActiveX to generate a 'JS Tree' type structure made up out nested table after nested table. In short, it is awful.</p> <p>The problem I am presented with, is to get it loaded into a database so they can apply states to the associated content.</p> <p>Parsing the XML file is not necessarily a problem for me, however getting the structure to flow correctly is. The file is not nested in a logical manner that would lend itself to easily creating the structure in the database/filesystem. The XML file consists of <code>Structure</code> nodes that contain a bit of information about that node and any relevant content in the filesystem.</p> <p>I was thinking of loading it into an MPTT type structure, but logically parsing the various nodes into what consists of Child/Parent relationships is where I am stumbling. Below is a sample of this XML file:</p> <pre><code> &lt;Structure nodeid="9D565FD65DE9464EA36F005866DBF3AE" ParentID = "6EEB45ED97634C9BB2730D7713255673" IsAddOnNode="True" IsCoreNode = "0" &gt; &lt;Name&gt;POS specific remarks&lt;/Name&gt; &lt;Sequence&gt;1&lt;/Sequence&gt; &lt;WBS&gt;1.1.3.1&lt;/WBS&gt; &lt;BackgroundColor&gt;#80FF00&lt;/BackgroundColor&gt; &lt;FontColor&gt;Black&lt;/FontColor&gt; &lt;Comments&gt;&lt;/Comments&gt; &lt;References&gt;&lt;/References&gt; &lt;/Structure&gt; &lt;Structure nodeid="A6F7E2F0728147BB88429545A6C490CA" ParentID = "B17AB99B64664624AAA41E220A9EAE59" IsAddOnNode="False" IsCoreNode = "0" &gt; &lt;Name&gt;Execution, Monitoring, and Controlling of Results&lt;/Name&gt; &lt;Sequence&gt;4&lt;/Sequence&gt; &lt;WBS&gt;1.1.4&lt;/WBS&gt; &lt;BackgroundColor&gt;&lt;/BackgroundColor&gt; &lt;FontColor&gt;White&lt;/FontColor&gt; &lt;Comments&gt; &lt;Comment AddOnID = "53539AB26B50472CAA2DF4E428605C87" Version="0.2"&gt;&lt;/Comment&gt; &lt;/Comments&gt; &lt;References&gt;&lt;/References&gt; &lt;/Structure&gt; &lt;Structure nodeid="EFCCA56742074A2A859FD1C547850ABA" ParentID = "A6F7E2F0728147BB88429545A6C490CA" IsAddOnNode="False" IsCoreNode = "0" &gt; &lt;Name&gt;Project Performance Reports&lt;/Name&gt; &lt;Sequence&gt;1&lt;/Sequence&gt; &lt;WBS&gt;1.1.4.1&lt;/WBS&gt; &lt;BackgroundColor&gt;&lt;/BackgroundColor&gt; &lt;FontColor&gt;White&lt;/FontColor&gt; &lt;Comments&gt;&lt;/Comments&gt; &lt;References&gt;&lt;/References&gt; &lt;/Structure&gt; </code></pre> <p>When it has been parsed with ActiveX, the structure (on the left navigation pane) is arranged like a standard outline or ordered list:</p> <pre><code>1. Project Preparation 1.1 Project Management 1.1.1 Phase Star-Up 1.1.1.1 Item 1 1.1.1.2 Item 2 1.1.1.3 Item 3 </code></pre> <p>And so forth. To the best of my understanding, these values that denote the section or subsection (1.1.1.2) are stored in the <code>WBS</code> tag of the <code>Structure</code> node. I think what I need to do is to parse those out and create the structure according to that. How to do that is where I am stumped.</p> <p>Also, there is also a <code>Sequence</code> node that sems to store information about what index child element it is off of its parent element.</p> <p><strong>What I would LIKE to do</strong></p> <p>What I would like to do is create a bunch of database entries (preferably in MPTT) so that I can easily generate a nav tree and then I can begin worrying about 'scraping' all the individual files so that I can store their content in the database also. Somehow, I need to parse the WBS node value to create its 'index' within the table.</p> <p>I am hoping that the solution is more simple than I am anticipating. Suggestions, a prod in the correct direction would be greatly appreciated.</p> <p>I was planning on using the TreeBehavior within CakePHP to manage this, but I don't necessarily have to use that to process the file. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload