-
Implement server client architecture based XML Parsing server with a choice of IPC.
-
Implement an xml parser which satisfies all conditions and restrictions as described below:
- **Sample XML file could be of type: **(see data.xml)
- XML tag would not contain any attribute. e.g. 1 // type="A" would not be there. Do not parse attributes.
- Every XML tag can contain another xml tag or value. Value could be a number( of any standard data type ), string or an array enclosed within []. An array can contain a string or a number but not another xml tag. [] is not a part of standard xml.
- There would not be any repeated tags within a tag. e.g. another .. would not appear within <planes_for_sale>..</...>.
-
Server side is XML Parser, it should meet the following conditions:
- It should return an error if a particular tag does not exist or if a particular array index is out of bound or invalid. This error should be provided to client on their query.
- Once the data is updated, the xml file should be saved to the disk by the xml server.
- XML file to be used is to be provided as a command line argument.
- XML does not provide any information about data type, but server would have to accomodate somewhere in its request by figuring out the datatype itself
-
Task is to query this xml tag from another process, i.e from client side process
-
Important things to note:
- No use of any library, either STL or any third party
- Second process which can communicate with the XML process should have IPC connection information as the command line argument itself.
- We need to provide an interactive interface on client side to query these tags and print the outcome.
-
Sample Queries from client side and their explanation:
GET("planes_for_sale.ad.year");
Explantion: this would return 1977 along with a probable data type.SET("planes_for_sale.ad.year", 1900 );
Explanation: and add some way to specify data type while setting the valueGET("planes_for_sale.ad.previous.0", 20);
Explanation: // 0 is the index of the array "previous"
- Launch 2 terminals : One for server and one for client
- On the server side terminal, execute these commands:
clang++ abserver.cpp -o abserver -std=c++17
./abserver -portnumber 9898 -filename data.xml
Note: These commands are for Mac so use g++ instead of clang++ if you are using linux
- On the client side terminal, execute these commands:
clang++ abclient.cpp -o abclient -std=c++17
./abclient -portnumber 9898 -hostservername Abhisheks-MacBook-Air.local
Note: These commands are for Mac so use g++ instead of clang++ if you are using linux. hostservername is localhost here, to know your localhost, use "hostname" on your terminal and use that. Here "Abhisheks-MacBook-Air.local" is my hostname.
- You can now query from the client process (see example queries above). Use "quit" as a query to terminate the program.
- To see the example queries, please check "abclient.cpp". I have written the examples as comments
- No STL library had to be used, therefore I implemented my own vector class
- There is no third party library used.
- Choice of IPC for here is connection through sockets
- Everything is in C++17
- 2 types of queries are allowed :
GET
andSET
- To see the list of data types supported, please check "abclient.cpp" or "abXMLParser.hpp".
- Since this the communication is between 2 process in the same computer I have used localhost as XML server
- Basic error handling is incorporated
For any query, please reach out to: [email protected]