Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML parsing

Status
Not open for further replies.

Kazzy

Programmer
Jul 21, 2003
20
US
I am getting a data fee from another company and I am having problems parsing the xml files (tags are not matching, etc). I have hundreds of mxl files similar to the one below..What is the best way to handle this...Or does the company that is providing the xml files needs to provided me with a well-formed xml file. I am new to XML so therefore I am not sure what to expect.

Thank you thank you.....

<?xml version="1.0"?>
<!DOCTYPE SEND_ITEM_DETAILS><LIFE><item>
<item-id>10283</item-id>
<item-content><html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<h4><font face="Arial, Helvetica, sans-serif" color="#FF0000">How to Reduce Holiday
Stress </font> </h4>
<p><font face="Arial, Helvetica, sans-serif" size="2" color="#189B6F">The hustle
and bustle of the holiday season can be fun and energizing -- and very stressful.
Here are some quick tips to help you have a less stressful, more enjoyable holiday
season.</font></p>
<ul><font color="#FF0000">
<li><font face="Arial, Helvetica, sans-serif" size="2" color="#189B6F">Keep
your plans manageable. Do not accept invitations to parties or places you do not
really want to go to. Pace yourself. Schedule in some time to yourself.<br>
</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="2" color="#189B6F">Drink
alcoholic beverages moderately, if at all. Drinking is a depressant and can
make holiday stresses even worse.<br>
</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="2" color="#189B6F">Keep
expectations reasonable. It is okay not to be happy and jolly all the time.
Give yourself permission to feel tired, overwhelmed, sad, frustrated or even
angry. <br>
</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="2" color="#189B6F">Spend
time with supportive friends or family members. <br>
</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="2" color="#189B6F">Get some
fresh air. Spending time outside, even on cloudy or overcast days, can refresh
you.</font></li></font>
</ul>
<h4><font face="Arial, Helvetica, sans serif" color="#189B6F">See also:</font></h4>
<a href=" face="Arial, Helvetica, sans serif" size="2">Secrets to Healthy Holiday Eating</font></a>
<br>
<a href=" size="2" face="Arial, Helvetica, sans serif">Coping With The Holiday Blues</font></a>

</body>
</html>
</item-content>
</item>
</life>
 
When using XML as a data transfer between 2 differents entities (what ever they may be), the rule is that the 2 parts (sender and receiver) discuss on the structure of the document in order for the 2 parts to talk the same language. Fortunately, XML provides a way to define data structure : the DTD. Ask your sender for DTD that will be your contractual data structure for all transferts. When receiving an XML, check it with the DTD. If DTD check fails, ask another XML that is contractual DTD compliant.

Water is not bad as long as it remains outside human body ;-)
 
You could ask them (or do it yourself) to put CDATA tags around the html section:
Code:
<![CDATA[
<html>
........
</html>
]]>


Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
how I can insert <![CDATA[...]]> tags in every file. Does this need to be done before parsing the file.? Sorry ...I am not that familiar with xml...thanks
 
Yes. If a file is not well-formed, it is not XML.

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Jonty, Can you emplain a little more on how you insert(automated) the <![CDATA[...]]> tags.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top