Used as a common and popular format to transport data, XML (the eXtensible Markup Language) uses tags to form a hierarchical structure that identifies and organizes data. It's important to understand the XML format, which can be read, written, and manipulated in the C language providing you have an XML library available.
- [Narrator] The C language has primitive data types, which are useful, but not up to speed with the complex data interchange formats used by more recent languages such as Javascript and Python. One of the most widely used data interchange formats is XML. XML data is stored as plain text. And this data can be accessed or created by linking in an XML library to your C code. XML is the Extensible Markup Language. It's a cousin to HTML, the formatting language used on the World Wide Web. XML is used to describe, store, and transport data. To describe data, XML uses tags. A tag is enclosed in angle brackets. One tag marks the start of a chunk of data, and it consists of a case-sensitive word. A closing tag marks the end of the data chunk, containing the same word, but prefixed by a slash (/). A single tag can also be used, though tag pairs are more common. Tags are user defined. You can use whatever tags you need, descriptive tags are best. The first line XML data is often a special tag called a prolog. The prolog defines the XML version, and character encoding. Here's a typical XML prolog tag, the tag lacks a closing tag. The next tag in the XML document is the root tag. Within the root tag are various child tags, and even sub-child tags. All these tags match up with closing tags. Tags also contain attributes, which are further descriptive elements. The attribute features a name, followed by an equal sign (=), and then a value enclosed in double or single quotes. No further rules describe how this data is configured. The decision is up to whoever creates the XML data. For the C language, a host of XML libraries are available. One I've used is libxml2, which is available from the website xmlsoft.org, shown here. If you're using a package manager, you can search for and install the libxml2-dev library. You can also opt to manually install the library, which is compatible with Code::Blocks in Windows. Documentation and sample code are available on the xmlsoft website.
Released
10/1/2019- Finding, installing, and linking libraries
- Accessing and generating XML data
- Working with JSON
- Working with the libcurl library
- Text programming
- Reading, writing, and manipulating JPEG images
- Working with PNG images
Share this video
Embed this video
Video: Understanding XML