-1

I am a total 0 in JS but I got a task to write a simple function of converting XML to HTML

Example:

<Translation code="200" lang="de-en">
<text>Cat</text>
</Translation>

'Cat' should be in HTML

XML structure doesn't change but the content of text node does

Yeah I can google couple of hours how to get it or ask here and close the task, appreciate any help

2
  • Do you really need a script to do that or maybe can you use an already existing tool like this one? Commented Mar 4, 2020 at 14:07
  • @Coldark no it is used in code Commented Mar 4, 2020 at 14:09

1 Answer 1

-1

The quickest is using jQuery

const xml = `<Translation code="200" lang="de-en">
<text>Cat</text>
</Translation>`

$("#content").text($(xml).find("text").text())
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="content"></div>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.