Re: XML decoding using a mapping file
Re: XML decoding using a mapping file
- Subject: Re: XML decoding using a mapping file
- From: Chuck Hill <email@hidden>
- Date: Mon, 31 Mar 2008 16:42:04 -0700
On Mar 31, 2008, at 3:35 PM, David Holt wrote:
I am attempting to decode the following return from a website and I
am OH SO CLOSE :-)
This is the xml:
<?xml version="1.0"?><SearchResult> <Count>2</Count> <IdList>
<Id>18326189</Id> <Id>18061844</Id> </IdList></SearchResult>
I am trying to get the list of IDs, but I can only get it as far as
the array "IdList". In my HTML component, I am using two WOStrings
to display the contents for testing and I get:
Count: 2
Idlist: ({Id = ("18326189", "18061844"); })
Where/how can I specify that ID should just be an integer? I can't
change the XML, that is fixed. The IdList tag is confounding my
attempts to get an array of ID's because ID ends up being an array
of integers the way I've mapped the XML.
The XML model file looks like this:
<model>
<entity name="ca.cscw.SearchResult" xmlTag="SearchResult"
ignoreUnmappedTags="YES">
<property name="count" xmlTag="Count" />
<property name="idlist" xmlTag="IdList" forceList="Yes"/>
I don't think you want forceList here.
Maybe?
<property name="idlist" xmlTag="IdList">
<entity name="java.lang.Integer" xmlTag="id" />
</property>
Chuck
</entity>
</model>
My class for the result is:
package ca.cscw;
import com.webobjects.foundation.NSArray;
public class SearchResult {
private String count;
private NSArray idlist;
public SearchResult() {
}
public String count() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public NSArray idlist() {
return idlist;
}
public void setIdlist(NSArray idlist) {
this.idlist = idlist;
}
}
Thanks for reading this far!
David
_______________________________________________
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
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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