|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
XML validation
Hi, I have a requirement where I need to validate the xmls that are getting generated by an application if it is well formed or not. If it has generated incomplete xml (such as missing tags), then I need to correct it using some UNIX commands and have to process it. I even gone through xmllint tool, but I could not understand how and what exactly it works and also could not understand how to use it. Could anyone please help on this? My XML look like below Code:
<?xml version="1.0" encoding="utf-8"?>
<ProductInformation WorkspaceID="afjeqoe">
<Qualifiers>
<Qualifier ID="1">
<DimensionPointLink DimensionPointID="eng"/>
</Qualifier>
<Qualifier ID="2">
<DimensionPointLink DimensionPointID="std.lang.all"/>
</Qualifier>
<Qualifier ID="3">
<DimensionPointLink DimensionPointID="USMarket"/>
</Qualifier>
<Qualifier ID="Qualifier root"/>
</Qualifiers>
<UnitList>
</ProductInformation> |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Assuming your XML document is called output.xml, here is what xmllint outputs: Code:
xmllint output.xml
output.xml:16: parser error : Opening and ending tag mismatch: UnitList line 15 and ProductInformation
</ProductInformation>
^
output.xml:17: parser error : Premature end of data in tag ProductInformation line 2
^It clearly shows that the error is on line 15 and is due to the UnitList element not having a matching opening and closing tag. This is correct. As to fixing XML documents that are not well formed, in the general case that is not possible due to too many variables. However if you have a good XML Schema, it is possible. |
| Sponsored Links | ||
|
![]() |
| Tags |
| validate xml using unix |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| XML: parsing of the Google contacts XML file | ripat | Shell Programming and Scripting | 9 | 12-25-2012 10:07 AM |
| How to add the multiple lines of xml tags before a particular xml tag in a file | mjavalkar | Shell Programming and Scripting | 0 | 06-25-2012 04:54 PM |
| XML file validation | bmk | Shell Programming and Scripting | 2 | 02-09-2012 07:05 AM |
| How to remove xml namespace from xml file using shell script? | Gary1978 | Shell Programming and Scripting | 10 | 10-26-2008 09:32 PM |
|
|