Need to convert some XML I’m receiving into HTML quickly. Do I need to bust out RegEx?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If XML contains data structure then use jQuery templating feature. This way you can define representation of each record/data structure in HTML. Along with jQuery if you use javascript MVC framework like AngularJS or Knockout you can convert your XML datastructure into HTML with minimal and maintainable code.
Example of jQuery Templates with KnockoutJS http://knockoutjs.com/documentation/template-binding.html
If XML contains HTML elements then you it would be easy for you to write XSL and do the conversion from XML to HTML. Javascript engines have XSL processors that can convert XML to HTML using XSL templates
Introduction to client-side XSLT for XML to HTML conversion: http://www.w3schools.com/xsl/xsl_client.asp