Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8572079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:55:32+00:00 2026-06-11T18:55:32+00:00

My assignment is to differentiate xml content in to groups , for example i

  • 0

My assignment is to differentiate xml content in to groups ,
for example
i have two xml files

<?xml version="1.0"?>
<marks>
<firstname>john</firstname>
<lastname>peter</lastname>
<subject name="english" marks="30">pass</heading>
</marks>

<?xml version="1.0"?>
<marks>
<firstname>james</firstname>
<lastname>cameron</lastname>
<subject name="english" marks="30" degree="masters">pass</heading>
</marks>

So i need to parse above example xml files and need to divide them in to groups, and calculate the number of master students, phd students, bachelor students

Each group will have and additional properties in element section, like for masters students subject element” will have an property degree for phd students they will an property of specialization

I can get the properties of the xml files and code it in the c function saying if we have property name degree consider them as masters students but is there any other way round like
construct the DTD based on the xml requests and just using libxml2 to validate the DTD and differentiate requests (which i have to figure it out by using libxml2 library, don’t know yet)

As the number of different type of xml request increases, i cannot hard code them writing multiple if loops.

it would be possible to just create a dtd for particular type of request and just using one line of code to validate against that request but now sure is it really possible..

request you to give your thoughts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:55:33+00:00Added an answer on June 11, 2026 at 6:55 pm

    I understand the question as given by the title: “how to validate xml based on the DTD by using libxml2 xml parse in c”. It’s quite easy to answer that. It is actually a duplicate of Dtd validation with libxml2 and should be closed for that reason.

    But then comes the description and it turns out that the question is quite different. You probably want some help with the design of your project. Maybe you should change the title a bit?

    As to your design: why don’t you want to use ifs? You want it to be possible to change it without recompiling the app? So you need to put down all the cases in a configuration file. Read the file and act accordingly.

    Trying to answer the design part:

    A separate dtd for each kind of request would also do, but then you would have to validate the xml against all the dtd sequentially. If the performance cost is acceptable, then you may go this way. All the dtds (or xsd schemas) may be read into memory in initialization phase and then be tried against the xml sample until it validates.

    To examine whether your xml contains given attribute in given element you may also use XPath from libxml. See this question and XPath examples. Pay attention to xmlXPathEvalExpression usage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an assignment to implement my own version of Collections.fill() and Collections.reverse(). The
My assignment asks that: Create a directory ~/UnixCourse/scriptAsst . Turn the two-line version, above,
My assignment is to write an overloaded version of iquote() , a method that
My assignment requires that I have an ER diagram that shows the dependencies between
I am doing an assignment with pyGame, a very simple one, we have to
I am doing an assignment and stuck at this point: I have a class
I have an assignment in which I need to create a function that tells
My assignment is to implement a multithreaded web server in Java but i have
Ok so for an assignment we have to make our first program. Mine is
I have an assignment where I have a tree where all the parent nodes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.