Skip to main content
The 2024 Developer Survey results are live! See the results
Clarification
Source Link
Glenn Carver
  • 135
  • 1
  • 2
  • 14

It's 2024, and I am working on a project that incorporates XSLT technology.

I came up with a simple way to access XML file that is being transoformed with javascript simply but outputing it to a hidden div, and then parsing it's content with XMLParser in JS.

<div class="hidden">
    <xsl:copy-of select="/*" />
</div>

Everything worked so far, I could access nodes with querySelector and attributes. Only problem I just noticed - if XML file has image node it is being converted to img

Something like that:

<div class="hidden">
    <object>
        <image>link</image>
    </object>
</div>

Converts to

<div class="hidden">
    <object>
        <img>link
    </object>
</div>

Which is completely wrong and breaks parsing. It only happens to this node. I don't really know what causes this - I am using IE11 compatability mode to transform XSLT stuff - any way to stop it from doing so? I obviously can't modify the XML since it comes from backend.

It's 2024, and I am working on a project that incorporates XSLT technology.

I came up with a simple way to access XML file that is being transoformed with javascript simply but outputing it to a hidden div, and then parsing it's content with XMLParser in JS.

<div class="hidden">
    <xsl:copy-of select="/*" />
</div>

Everything worked so far, I could access nodes with querySelector and attributes. Only problem I just noticed - if XML file has image node it is being converted to img

Something like that:

<object>
    <image>link</image>
</object>

Converts to

<object>
    <img>link
</object>

Which is completely wrong and breaks parsing. It only happens to this node. I don't really know what causes this - I am using IE11 compatability mode to transform XSLT stuff - any way to stop it from doing so? I obviously can't modify the XML since it comes from backend.

It's 2024, and I am working on a project that incorporates XSLT technology.

I came up with a simple way to access XML file that is being transoformed with javascript simply but outputing it to a hidden div, and then parsing it's content with XMLParser in JS.

<div class="hidden">
    <xsl:copy-of select="/*" />
</div>

Everything worked so far, I could access nodes with querySelector and attributes. Only problem I just noticed - if XML file has image node it is being converted to img

Something like that:

<div class="hidden">
    <object>
        <image>link</image>
    </object>
</div>

Converts to

<div class="hidden">
    <object>
        <img>link
    </object>
</div>

Which is completely wrong and breaks parsing. It only happens to this node. I don't really know what causes this - I am using IE11 compatability mode to transform XSLT stuff - any way to stop it from doing so? I obviously can't modify the XML since it comes from backend.

Source Link
Glenn Carver
  • 135
  • 1
  • 2
  • 14

XSLT converts <image> node to <img> tag when outputiing to DOM

It's 2024, and I am working on a project that incorporates XSLT technology.

I came up with a simple way to access XML file that is being transoformed with javascript simply but outputing it to a hidden div, and then parsing it's content with XMLParser in JS.

<div class="hidden">
    <xsl:copy-of select="/*" />
</div>

Everything worked so far, I could access nodes with querySelector and attributes. Only problem I just noticed - if XML file has image node it is being converted to img

Something like that:

<object>
    <image>link</image>
</object>

Converts to

<object>
    <img>link
</object>

Which is completely wrong and breaks parsing. It only happens to this node. I don't really know what causes this - I am using IE11 compatability mode to transform XSLT stuff - any way to stop it from doing so? I obviously can't modify the XML since it comes from backend.