Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

DOM question

Can anyone tell me, is a documentElement object the same type of object that is created by createContextualFragment?  

 var range = document.createRange()
 var newnode = range.createContextualFragment(rawxml);
SOLUTION
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HLRosenberger

ASKER

ok, then how can I take raw SVG string like below that is not a fragment, and load it into, or more correctly, merge it with what's already in the DOM?  I am able to use the two lines of code from above to create a  fragment node, and then add that node to the DOM.   like : SVGLayer.node().appendChild(newnode);

I actually using D3 and SVG as well and the resulting newnode that I add is not acting as it should as far as D3 methods and SVG.  I know this explaination is outside the scope of my question, but I'm just providing some context.  I'm guessing that I'm having issues because I'm create a fragment out of something that is not a fragment, but a full-blown SVG/XML file.  


<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
       viewBox="0 0 1040 792" style="enable-background:new 0 0 1040 792;" xml:space="preserve" >
<style type="text/css">
      .st1{fill:#8cc800;stroke:#000000;stroke-width:2;stroke-miterlimit:10;}
      .st2{fill:black;}
</style>
<g id="airport" >
      <g id="section-postSecurity" >
            <path id="postSecurity" class="st1" d="M665.8,636.7c0-6.7,0-130.4,0-130.4h77.3v-34.7h22v-10h-23.3v-24c0,0,88.7,3.3,88.7,0
                  s0-42,0-42s-128,2-128,0s0-42.7,0-42.7h-70v-13.3h-4.7v-152h-27.3v-73.3l43.3-13.3l26,22c0,0,90.7-25.3,91.3-27.3
                  c0.7-2-27.3-80.7-27.3-80.7L668,36.9l-0.3,0.2l-2.6-9.5l-44.6,14l-70,2l-26.7,84.7l29.3,9.3V339h15.4v19.3h-67.4v72h50v78.3h-46.6
                  v7.7h-30V559h62v10.6h-66.7v24.7h-24.7l0.1,53.5l219.7-10.6L665.8,636.7z"/>
            
            <text transform="matrix(1 0 0 1 550 400)" class="st2" >Post-Security</text>
                  
      </g>
      <g id="section-preSecurity" class="st0">
            <polygon id="preSecurity" class="st1" points="446,648.5 666.9,635.3 1028.3,635.3 1028.3,723.3 962,723.3 962,729 930,729 930,749 9.7,749
                  9.7,652.3 29.7,652.3 29.7,612 77.3,612 77.3,619 407,619 406.8,611.6 414.5,611.6 429.1,626.3 429.1,634.3 436.5,634.3
                  436.5,648.3 445.1,648.3       "/>
                  
            <text transform="matrix(1 0 0 1 500 700)" class="st2"  >Pre-Security</text>      
      </g>
</g>
</svg>
ah, you misunderstood my question and/or I did not state it correctly.  I mean is an object of type documentElement the same or equivalent to an object created by createContextualFragment?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it works!  does what I need.