Closed sijuthankachan closed 9 years ago
The following nested template should do what you want:
var template = [
'//label', { 'id': '@id', 'added': '@added,
'address': [ 'address', { 'street': 'street', 'city': 'city' } ]
} ];
The address field selector just needs to be another jath array template.
the above code didnt help me.. please
this is my original XMl Structure.
<data>
<list>
<item>
<map>
<prdid>1</prdid>
<prdname>Product 1</prdname>
<prddec>Product 1 Dec</prddec>
<prddate>2012-06-19 05:57:28.0</prddate>
<type>true</type>
</map>
</item>
<item>
<map>
<prdid>2</prdid>
<prdname>Product 2</prdname>
<prddate>2012-06-14 11:38:30.0</prddate>
<type>true</type>
<prddec>
<list>
<item>
<map>
<text>Product 2 Dec Title 1</text>
<type>Product 2 Dec Type 1</type>
</map>
</item>
<item>
<map>
<text>Product 2 Dec Title 2</text>
<type>Product 2 Dec Type 2</type>
</map>
</item>
<item>
<map>
<text>Product 2 Dec Title 2</text>
<type>Product 2 Dec Type 2</type>
</map>
</item>
</list>
</prddec>
</map>
</item>
<item>
<map>
<prdid>3</prdid>
<prdname>Product 3</prdname>
<prddec>Product 3 Dec</prddec>
<prddate>2012-06-14 11:38:28.0</prddate>
<type>true</type>
</map>
</item>
</list>
</data>
</map>```
and i need the jath template for this
```[
{
prdid: "1",
prdname: "Product 1",
prddec: "Product 1 Dec"
prddate: "2012-06-19 05:57:28.0",
type: "true"
},
{
prdid: "2",
prdname: "Product 1",
prddec: [
{
text:'Product 2 Dec Title 1'
type:'Product 2 Dec Type 1'
},
{
text:'Product 2 Dec Title 2'
type:'Product 2 Dec Type 2'
},
{
text:'Product 2 Dec Title 3'
type:'Product 2 Dec Type 3'
},
]
prddate: "2012-06-14 11:38:30.0",
type: "true"
},
{
prdid: "3",
prdname: "Product 3",
prddec: "Product 3 Dec"
prddate: "2012-06-14 11:38:28.0",
type: "true"
}
]```
is it possible with Jath?
Your
<prddec>
Field has 2 different formats. There is no alternation in Jath currently, so I think you'd have to allow for 2 output fields, for example, "prddec" and "prddec_full".
Here is a sample snippet:
{ 'prddec': 'prddec', 'prddec_full': [ 'list/item', { 'text': 'map/text', 'type': 'map/type' } ] }
I haven't tested it, I'm just trying to show the basic idea.
I'm going to think about supporting some kind of conditional template or alternation, but I'm not sure what that's going to look like yet. Let me know if you have any syntax suggestions.
how can we write a template for the following xml
My XML style