Possible bug(s) or me just being stupid, you decide

Oct 29, 2009 at 12:47 AM

A little background to my problem.

I am attempting to create a dynamic CMS system using custom tags within a html document. These tags are parsed by HAP and I then insert the information in the tags into the database for later use. This process works fine, the problem occurs when I attempt to manipulate the html at a later stage.

One of the tags I am using is a <list>. Please dont slate me for doing it this way, I needed a quick solution to demostrate something to a potential client and decided this was a good way. Anyway, the HTML will have sections like this;

 <list name="sidenav" description="Side Navigation">
                          <h3>
                            <field type="image" name="sidenav_header" description=" Header Image with Link" link="true"></field>
                          </h3>
                          <table >
                            <tr>
                              <td ><field type="image" name="sidenav_content_image" description="Content Image" groupname="sidenav" link="false"></field></td>
                              <td><p>
                                  <field type="field" name="sidenav_content" description="Content with Link" link="true"></field>
                              </p></td>
                            </tr>
                          </table>
                        </list>

Which is then in the database. The user would then come along and add 'list' items, these are made up on the admin screen on the <field>'s found in the <list>. Again the B side works fine.

Now the process needs to take these list entries and insert them into the content that was previously saved. This process is as follows;

For each list, build the content from the DB. (works fine and produces standard html)
Find the <list> tag in the doc and change the innerhtml  of the node to the generated content.
Get the parent node.
Removenode using parent.removenode(child, true)

Now this is where my problems start. It removes the node, but the contents that were generated become mixed up. The generated content looks like this;

<h3> <img src="/file.aspx?id=3477"> </h3>
<table>
  <tr>
    <td><img src="/file.aspx?id=3478"></td>
    <td><p> fsafaf </p></td>
  </tr>
</table>

Which is you can see, matched the layout defined in the <list> above. However, after calling RemoveNode, it looks like this;


<table>
  <tr>
    <td><img src="/file.aspx?id=3478"></td>
    <td><p> fsafaf </p></td>
  </tr>
</table>
<h3> <img src="/file.aspx?id=3477"> </h3>

Is this something that can be explained.

My second problem was encountered by findiing my own solution to the first.

The process went like this;

For each list, build the content from the DB. (works fine and produces standard html)
Find the <list> tag in the doc and change the innerhtml to ""
Get the parent node.
Removenode using parent.removenode(child, true)
Insert generated content at n.OuterStartIndex.

Now, I have not looked at the HAP code in huge detail, but would have assumed that this would give me the startposition of <list> in the doc.

 

 

 

 

So the doc would look something like this;


<table><tr><td>
<list name="sidenav" description="Side Navigation">
                          <h3>
                            <field type="image" name="sidenav_header" description=" Header Image with Link" link="true"></field>
                          </h3>
                          <table >
                            <tr>
                              <td ><field type="image" name="sidenav_content_image" description="Content Image" groupname="sidenav" link="false"></field></td>
                              <td><p>
                                  <field type="field" name="sidenav_content" description="Content with Link" link="true"></field>
                              </p></td>
                            </tr>
                          </table>
                        </list>
</td></tr></table>

Based on this, I would assume (and can see from debug) that getting the list node, and setting the innerhtml to "" would leave me with this;

<table><tr><td>
 </td></tr></table>

Using the supposed outerstartindex, insert the generated HTML and I would expect this;


<table><tr><td>
<list name="sidenav" description="Side Navigation">
</list>
 </td></tr></table>

Note that I have checked node.outerstartindex before and after this and they are the same.

Now remove the child using the parent;

 

<table width=\"192\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"sidebar\">
  <tr>
    <td>
      <h3> <img src=\"/file.aspx?id=3477\"> </h3>
      <table>
        <tr>
          <td><img src=\"/file.aspx?id=3478\"></td>
          <td><p> fsafaf </p></td>
        </tr>
      </table>
      </td>
  </tr>
</table>

Yet, I get this;

<table width=\"192\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"sidebar\">
  <tr>
    <td></
      <h3> <img src=\"/file.aspx?id=3477\"> </h3>
      <table>
        <tr>
          <td><img src=\"/file.aspx?id=3478\"></td>
          <td><p> fsafaf </p></td>
        </tr>
      </table>
      td>
  </tr>
</table>

Which appeared to me at this point to be 2 chars out. To confirm this, I added this code jsut before;

int pos = string.IndexOf("<list");

and yes, it was 2 chars difference (3345 from HAP, 3343 from IndexOf.

SO i changed my code to check myself where the pos was and it all works fine now, but is this a bug somewhere or am I mistunderstanding it.

Apologies for the long post.

Thanks

<font size="1">

 

</font>