tags:

views:

69

answers:

2

I want to parse this file in Cocoa Application.but no parser for xml work well.Please help for parsing this file or other xml files like this. Thanks... My Xml File is as Under:

Hiren

<property id=\"license\">
  <object> 
     <property id=\"color\">
     <string>red</string>
     </property>
     <property id=\"expiresOn\"> 
      <string>10-10-2010</string>
     </property>
     <property id=\"Note\"> 
      <string>This licence is valid to <[email protected]> until 10-10-2010</string>
     </property>
  </object>
</Property>

A: 

Have you considered using the DOM? A quick Google search shows that Apple's libraries provide a DOM implementation. Then it's just a matter of finding the right Element and calling getAttribute on it to find the values of the various attributes.

avpx
But it not help me parsing the file when there are angle brackets in string also when i don't know before which attributes are there...So if you have any more suggestions then pls tell me...
Hiren Gujarati
avpx
+3  A: 

I want to parse this file in Cocoa Application.but no parser for xml work well.

The parsers work fine. Your input is broken; it isn't valid XML.

There are two things wrong with it:

  1. The quote marks are backslash-escaped. (Maybe you escaped them for Stack Overflow? If so, don't do that.)
  2. The value of the string element within the property#Note element contains unescaped angle brackets.

Your input is broken; therefore, you cannot parse it as XML. If you want to parse XML, you need valid XML to parse.

Peter Hosey