I am writing a document which has both java and xml codes, I managed to highlight my java code but unfortunately I was unable to do the same with xml, so far I have tried more than one way either by including the style set or by modifying the lstlisting file and add key words, I dont know what is the issue exactly my xml code still not highlighted !!!! I appreciate any support Thanks in advance !


As you haven't supplied a minimal working example it is not clear what you have tried, but doesn't specifying the language for each listing environment do what you want? For example, you can highlight the following java and xml code snippets like this

enter image description here

by typing:



  public class HelloWorld
    public static void main(String[] args) {
      System.out.println("Hello World!");

  <?xml version="1.0" encoding="UTF-8"?>
      <name>Joe Tester</name>
      <street>Baker street 5</street>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.