Mike is right Vaibhav! I've tested the code. I think you need to review your xml and object class too.
Here is an example. I've a class called Abc which implements WOXMLCoding:
public class Abc implements WOXMLCoding { public String value; public Class classForCoder() { return this.getClass(); }
public void encodeWithWOXMLCoder(WOXMLCoder cod) { }
public Abc(WOXMLDecoder dec) { value = (String) dec.decodeObjectForKey("value"); } }
Here is the xml:
<element objectID="1" type="Abc"> <value objectID="2" type="java.lang.String"> <![CDATA[ <p>Some content.</p><h4>Heading></h4><p>Some more content.</p> ]]> </value> </element>
This works perfect.
public static void main(String[] args) { WOXMLDecoder dec = WOXMLDecoder.decoder(); NSData data = "" style="color: #8e0068">new NSData( "<element type=\"com.fuegocms.application.Abc\" objectID=\"1\"><value objectID=\"2\" type=\"java.lang.String\"><![CDATA[<p>Some content.</p><h4>Heading></h4><p>Some more content.</p>]]></value></element>", "UTF8"); Abc abc = (Abc) dec.decodeRootObject(data); System.err.println(abc.value); }
Console output:
<p>Some content.</p><h4>Heading></h4><p>Some more content.</p>
Farrukh
On 2011-01-12, at 12:56 AM, Mike Schrag wrote: you're going to have to escape those tags or it's always going to try to parse it as xml ... if cdata didn't work you can try escaping it with ERXStringUtilities.escapeNonXMLChars.
ms On Jan 11, 2011, at 4:51 PM, Farrukh Ijaz wrote: Hi,
Try following in your XML. Instead of using <value>...</value> use <value type="java.lang.String">...</value>
Or use mapping file.
HTH.
Farrukh On 2011-01-11, at 10:41 PM, vaibhav srivastava wrote: Hi ,
That is fine . But , I want these values to go as the paling text ...when , I am wrapping it around CDATA whole thing is getting ignored . I want to parse html tags as plain text.
Regards Vaibhav On Tue, Jan 11, 2011 at 11:18 AM, Mike Schrag <email@hidden> wrote:
wrap that value in a cdata - http://www.w3schools.com/xml/xml_cdata.asp
ms On Jan 11, 2011, at 2:03 PM, vaibhav srivastava wrote: HI Farrukh,
Thanks for early reply I have gone through this documentation already.
my XML looks like <abc> <df>featuresDescription</df>
<eh> <lang>en-us</lang> <value><p> Some content.</p>
<h4>Heading>
<p>Some more content.</p></value> </eh> </abc> Now when i use WOXMLDecoder to parse it i want these html tags to be parsed as normal text instead they are converting into one more key value pair.
like <value p="some content">
any suggestion
On Tue, Jan 11, 2011 at 2:31 AM, Farrukh Ijaz <email@hidden> wrote:
Hi,
Did you check in the documentation before using WOXMLDecoder?
http://www.webobjects.me/API/wo542/com/webobjects/appserver/xml/WOXMLDecoder.html
Can you share the code to properly understand the problem?
You can always get the string using valueForKey method on the dictionary.
Farrukh
On 2011-01-11, at 4:41 AM, vaibhav srivastava wrote:
> Hi All,
>
> I am facing trouble with WOXMLDecoder class while parsing it.
>
> In my xml, I have <p> abc <p> .... while debugging found that it is converting this html tag to {p=abc}.
>
> and thus giving cast exception NSMutableDictonary cannot be converted to java.lang.String
>
>
> Any suggestions on this?
>
> Thanks for help in advance.
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ( email@hidden)
This email sent to email@hidden
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
|