HTML

Source code

import QtWebService.HTML 5.0

Html {
    lang: "en"
    Head {
        Meta { charset: "utf-8" }
        Title { text: "test page" }
    }

    Body {
        H1 { text: "Hello, world!" }
        P { text: "This is how HTML looks like on QtWebService." }
    }
}
Download source code

Output

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><title>test page</title></head><body><h1>Hello, world!</h1><p>This is how HTML looks like on QtWebService.</p></body></html>
Open output

CSS

Source code

import QtWebService.CSS 3.0

Css {
    Rule {
        selector: 'body'
        background_color: 'red'
    }
}
Download source code

Output

body {
    background-color: red;
}
Open output

JSON

Source code

import QtWebService.JSON 1.0

Json {
    object: { "greetings": "Hello, world!" }
}
Download source code

Output

{
    "greetings": "Hello, world!"
}
Open output

XML

Source code

import QtWebService.XML 1.0

Tag {
    tagName: 'quiz'
    Tag {
        tagName: 'question'
        text: 'Who was the forty-second president of the U.S.A?'
    }
    Tag {
        tagName: 'answer'
        text: 'William Jefferson Clinton'
    }
    Comment {
        text: ' Note: We need to add more questions later.'
    }
}
Download source code

Output

<?xml version="1.0" encoding="UTF-8" ?><quiz><question>Who was the forty-second president of the U.S.A?</question><answer>William Jefferson Clinton</answer><!-- Note: We need to add more questions later.--></quiz>
Open output

Text

Source code

import QtWebService.Text 1.0

Text {
    text: 'Hello, world!'
}
Download source code

Output

Hello, world!
Open output