\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{PotatoCodes} \pdfinfo{ /Title (xml.pdf) /Creator (Cheatography) /Author (PotatoCodes) /Subject (Xml Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{51DBA4} \definecolor{LightBackground}{HTML}{F4FCF9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Xml Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{PotatoCodes} via \textcolor{DarkBackground}{\uline{cheatography.com/205795/cs/44014/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}PotatoCodes \\ \uline{cheatography.com/potatocodes} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 3rd August, 2024.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Syntax}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}root\textgreater{} \{\{nl\}\}~~\textless{}child\textgreater{} \{\{nl\}\}~~~\textless{}subchild\textgreater{}.....\textless{}/subchild\textgreater{} \{\{nl\}\}~~\textless{}/child\textgreater{} \{\{nl\}\}\textless{}/root\textgreater{}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\textless{}note\textgreater{} \{\{nl\}\}~~\textless{}to\textgreater{}Tove\textless{}/to\textgreater{}\{\{nl\}\}~~ \textless{}from\textgreater{}Jani\textless{}/from\textgreater{} \{\{nl\}\}~~\textless{}heading\textgreater{}Reminder\textless{}/heading\textgreater{} \{\{nl\}\}~~\textless{}body\textgreater{}Don't forget me this weekend!\textless{}/body\textgreater{} \{\{nl\}\}\textless{}/note\textgreater{}} \tn % Row Count 8 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Commenting}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}!-{}- This is a comment -{}-\textgreater{}} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Prolog}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textless{}?xml version="1.0" encoding="UTF-8"?\textgreater{}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{UTF-8 is the default character encoding for XML documents.} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{The XML prolog is optional.} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.12 cm} p{6.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Entity References}} \tn % Row 0 \SetRowColor{LightBackground} \textless{} & \< \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textgreater{} & \> \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \& & \& \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} ' & \' \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} " & \" \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{HttpRequest}} \tn % Row 0 \SetRowColor{LightBackground} The first line in the example above creates an XMLHttpRequest object: & var xhttp = new XMLHttpRequest(); \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} The onreadystatechange property specifies a function to be executed every time the status of the XMLHttpRequest object changes: & \seqsplit{xhttp.onreadystatechange} = function() \tn % Row Count 11 (+ 7) % Row 2 \SetRowColor{LightBackground} When readyState property is 4 and the status property is 200, the response is ready: & if (this.readyState == 4 \&\& this.status == 200) \tn % Row Count 16 (+ 5) % Row 3 \SetRowColor{white} The responseText property returns the server response as a text string.The text string can be used to update a web page: & \seqsplit{document.getElementById("demo").innerHTML} = xhttp.responseText; \tn % Row Count 22 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{var xhttp = new XMLHttpRequest(); \newline xhttp.onreadystatechange = function() \{ \newline \{\{nl\}\}\{\{nl\}\}if (this.readyState == 4 \&\& this.status == 200) \{ \newline \{\{nl\}\}\{\{nl\}\}\{\{nl\}\} // Typical action to be performed when the \{\{nl\}\}\{\{nl\}\}document is ready: \newline \seqsplit{document.getElementById("demo").innerHTML} = xhttp.responseText; \newline \{\{nl\}\}\{\{nl\}\} \} \newline \}; \newline xhttp.open("GET", "filename", true); \newline xhttp.send();} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Element Naming}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Case-sensitive} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Must start with a letter or underscore} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Cannot start with the letters xml (or XML, or Xml, etc)} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Can contain letters, digits, hyphens, underscores, and periods} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Cannot contain spaces} \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Element}} \tn % Row 0 \SetRowColor{LightBackground} An element can contain: & -text \{\{nl\}\}-attributes \{\{nl\}\}-other elements \{\{nl\}\}-or a mix of the above \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Empty Element & \textless{}element/\textgreater{} \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} Text Content & \textless{}title\textgreater{}, \textless{}author\textgreater{}, \textless{}year\textgreater{}, \textless{}price\textgreater{} contain text \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} element contents & \textless{}bookstore\textgreater{} and \textless{}book\textgreater{} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} attribute & \textless{}book\textgreater{} has an attribute (category="children"). \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Example: \newline \textless{}bookstore\textgreater{} \newline ~\textless{}book category="children"\textgreater{} \newline ~~\textless{}title\textgreater{}Harry Potter\textless{}/title\textgreater{} \newline ~~\textless{}author\textgreater{}J K. Rowling\textless{}/author\textgreater{} \newline ~~\textless{}year\textgreater{}2005\textless{}/year\textgreater{} \newline ~~\textless{}price\textgreater{}29.99\textless{}/price\textgreater{} \newline ~\textless{}/book\textgreater{} \newline ~\textless{}book category="web"\textgreater{} \newline ~~\textless{}title\textgreater{}Learning XML\textless{}/title\textgreater{} \newline ~~\textless{}author\textgreater{}Erik T. Ray\textless{}/author\textgreater{} \newline ~~\textless{}year\textgreater{}2003\textless{}/year\textgreater{} \newline ~~\textless{}price\textgreater{}39.95\textless{}/price\textgreater{} \newline ~\textless{}/book\textgreater{} \newline \textless{}/bookstore\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Attributes}} \tn % Row 0 \SetRowColor{LightBackground} Must be quoted ' ' or " " & \textless{}person gender="female"\textgreater{} \{\{nl\}\}or \{\{nl\}\}\textless{}person gender='female'\textgreater{} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} If contains quotues & \textless{}gangster name='George "Shotgun" Ziegler'\textgreater{} \{\{nl\}\}or \{\{nl\}\}\textless{}gangster name="George \"Shotgun\" Ziegler"\textgreater{} \tn % Row Count 8 (+ 5) % Row 2 \SetRowColor{LightBackground} Attributes cannot contain: & -multiple values (elements can) \{\{nl\}\}- tree structures (elements can) \{\{nl\}\}-are not easily expandable (for future changes) \tn % Row Count 14 (+ 6) % Row 3 \SetRowColor{white} ID referneces & \textless{}note id="501"\textgreater{} \{\{nl\}\}Can be used to idenmify xml elements \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.36 cm} x{4.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Namespaces}} \tn % Row 0 \SetRowColor{LightBackground} Fix name conflict with prefix & \textless{}h:table\textgreater{} and \textless{}f:table\textgreater{} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Xmlns defenition & \textless{}h:table xmlns:h="http://www.w3.org/TR/html4/"\textgreater{}\{\{nl\}\} or \{\{nl\}\}\textless{}root xmlns:h="http://www.w3.org/TR/html4/"\textgreater{} \tn % Row Count 7 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}