troubleshooting Question

Perl newbie needs regexp to extract multiline data between <para></para> in multiple xml files

Avatar of Letterpart
LetterpartFlag for United Kingdom of Great Britain and Northern Ireland asked on
4 Comments1 Solution537 ViewsLast Modified:
I am going mad and need some experts help please.

I am trying to extract the data between the first <para></para> in 12 xml files, but  because the data spans several lines, I can't get it to work.

So far I have tried every idea I have seen on the web but no luck, I either get the wrong paragraph, too little or too much.

As I have just started out in Perl, I would appreciate answers that are more than just a link or one line of reg exp as I want to get away from CTRL C + V coding and understand what it is I am doing. To this end, I have put the points at 125 (I know, not huge but...) as I would like a quick explanation of what the regexp is doing.

I may not respond to your answers immediately as I am lying down in a dark room with a cold wet flannel across my forehead just now.

One of the files I am working on is:

<?xml version="1.0"?>
<?xpp file-name;57_09_Miller.xml?>
<!DOCTYPE book PUBLIC "-//Letterpart//DTD Letterpart Book//EN"><?xpp MAIN;1;0;0;0;137;0;0?><book><title abb-r-head="Philosophy"><?xpp xych;1?>Philosophy</title><chapter section="miller"><title abb-r-head="Need, Care and Obligation">Need, Care and Obligation</title> <source>Sarah Clark Miller</source> <para>All humans experience needs.<?xpp foot;f1;an?><?xpp FOOT;f1;1?><footnote-para> I would like to thank Soran Reader for her very helpful comments on this article.</footnote-para> <?xpp /FOOT?>
At times needs cut deep, inhibiting persons&rsquo; abilities to act as agents in the world, to live in distinctly human ways, or to achieve life goals of significance to them. In considering such potentialities, several questions arise: Are any needs morally important, meaning that they operate as morally relevant details of a situation? What is the correct moral stance to take with regard to situations of need? Are moral agents ever required to tend to others&rsquo; well-being by meeting their needs? What justification or foundation, if any, can be given for requiring moral agents to respond to others&rsquo; needs?<?xpp foot;f2;an?><?xpp FOOT;f2;1?><footnote-para> As a variety of philosophers have it, the scope or extent of our obligation to help others runs the gamut between two extreme positions: the minimal libertarian position that we must only respect the rights of others, leaving charity as optional, not mandatory, and a maximal position like that of Peter Singer&rsquo;s, through which we are required to give to the needy until we are diminished to their level of need. Thomas Hill identifies these two extreme positions in &lsquo;Meeting Needs and Doing Favors&rsquo;. See T. Hill, Jr., <?xpp italic?>Human Welfare and Moral Worth: Kantian Perspectives<?xpp /italic?> (Oxford: Clarendon, 2002), 201&#8211;243. The Singer position (a consequentialist one) can be famously found in his earlier piece, &lsquo;Famine, Affluence, and Morality&rsquo;, <?xpp italic?>Philosophy and Public Affairs<?xpp /italic?> <?xpp bold?>1<?xpp /bold?>, No. 1 (Spring 1972), 229&#8211;43. Singer has somewhat modified his position in more recent work. See P. Singer, <?xpp italic?>One World<?xpp /italic?> (New Haven: Yale University Press, 2002).</footnote-para> <?xpp /FOOT?>
</para> <para>In answering these questions, my argument will take place in several parts. I begin explanatorily, describing care ethics for those unfamiliar with this particular ethical approach. This discussion reveals that care ethicists assert the moral importance of needs. Their position, however, does not offer comment on whether or not we are required to respond to the needs of others. I propose that our human interdependence and finitude give rise to an obligation to care for a certain subset of needs, namely, the constitutive needs of others. Through analysis of both the <?xpp italic?>Groundwork<?xpp /italic?> and the <?xpp italic?>Metaphysics of Morals<?xpp /italic?>, I present an interpretation of Kant&rsquo;s duty of beneficence that lays the foundation for the duty to care. After acknowledging the strengths of the Kantian approach, I cite one of <?xpp /MAIN?>
<?xpp MAIN;2;0;0;0;138;0;0?>its most significant shortcomings: although helpful in clarifying the foundation and scope of the duty to care, Kantian ethics requires supplementation with regard to content. Insights from feminist care ethicists provide indispensable enhancement, promoting a robust sense of the content of the duty to care, as represented by two elements: (1) the importance of moral perception and moral judgment in establishing how best to care for others and (2) dignifying care, a notion demonstrating that it is not enough <?xpp italic?>that<?xpp /italic?> we meet the needs of others, as <?xpp italic?>how<?xpp /italic?> we do so seriously affects both the agency and dignity of those in need.</para> <head-a><title abb-r-head="1. Care Ethics: Methods and Themes">1. Care Ethics: Methods and Themes</title> <para>The appearance of Carol Gilligan&rsquo;s <?xpp italic?>In a Different Voice<?xpp /italic?><?xpp foot;f3;an?><?xpp FOOT;f3;1?><footnote-para> C. Gilligan, <?xpp italic?>In a Different Voice: Psychological Theory and Women&rsquo;s Development<?xpp /italic?> (Cambridge, Mass.: Harvard University Press, 1982). See also C. Gilligan, &lsquo;Moral Orientation and Moral Development&rsquo; in <?xpp italic?>Women and Moral Theory<?xpp /italic?>, ed. E. F. Kittay and D. T. Meyers (Totowa, NJ: Rowman and Littlefield, 1987), 19&#8211;33. To understand the theoretical framework that Gilligan was arguing against, see L. Kohlberg, <?xpp italic?>The Philosophy of Moral Development: Moral Stages and the Idea of Justice<?xpp /italic?> (San Francisco: Harper and Row, 1981).</footnote-para> <?xpp /FOOT?>

many thanks,

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros