Code Monkey home page Code Monkey logo

xml-processing's Introduction

xml-processing

Examples for XML processing in different programming languages.

The exercises below are simple instances of common real-world XML processing tasks: selection of elements, modification of element content, modification of the XML tree and validation against an XML schema. The example XML file and the underlying schema can be found in the xml directory.

Feel free to send pull requests for solutions in additional languages or for improvements of the existing solutions!

Exercises

Exercise 1

Print a list of all leaf node creators and titles, i.e., all content/creator and content/title children of node elements that contain no other node elements as children. Each item should be a line of the form "creator, title".

Exercise 2

Same as exercise 1, but consider the case where some leaf nodes have no creator element. Search their ancestors until a creator element is found and print that instead.

Exercise 3

Make the content of all title elements uppercase. Print the resulting XML document.

Exercise 4

Add a new item to the end of the "A Song of Ice and Fire" section with title "A Feast for Crows" and date "2005". Print the resulting XML document.

Exercise 5

Remove the "Programming Books" section. Print the resulting XML document.

Exercise 6

Validate the XML document. Keep in mind that the schema file references additional external schema files that have to be retrieved from the internet, so internet access is required for validation.

Exercise 7

Flatten the XML hierarchy by removing the top level nodes (those immediately below the tree root element). Add a content/subject element to all their immediate child nodes that preserves the name attribute value of the removed parent node ("Programming Books" or "Fantasy Books", respectively). Print the resulting XML document.

Exercise 8

Reverse exercise 7: Create a new top level node for each distinct subject found in the current top level nodes. Move each node to its respective parent node (one of the new top level nodes). Remove the subject elements. Print the resulting XML document.

xml-processing's People

Contributors

marhop avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.