Page 1 of 1
xml
Posted: Wed Jun 06, 2001 3:18 pm
by jlin
Hi,
I ran into this when parsing the following xml document:
<document>
<item>
<feature>
<feature_type>product</feature_type>
</feature>
<feature>
<type>brand</type>
</feature>
</item>
</document>
Here is the schema I was using:
xml
trimspace
field Feature_type varchar document/item/feature/type ''
How do I make sure each Feature_type has its individual value?
Thanks.
xml
Posted: Wed Jun 06, 2001 3:55 pm
by mark
I'm not sure what you're asking.
Also feature_type is not the same as feature/type.
xml
Posted: Wed Jun 06, 2001 5:26 pm
by jlin
Hi Mark,
I am sorry, that was confusing.
all the sub elements under <feature> are the same. the correct xml should be:
<document>
<item>
<item_id>1</item_id>
<name>abc</name>
<address>def</address>
<feature>
<type>product</type>
<name>shoes</name>
</feature>
<feature>
<type>product</type>
<name>jewelry</name>
</feature>
<feature>
<type>brand</type>
<name>abc</name>
</feature>
..
</item>
</document>
and the schema:
xml
trimspace
field Item_id varchar document/item/item_id ''
field Feature_type varchar document/item/feature/type ''
field Feature_name varchar document/item/feature/name ''
my question is: when timport loops through each item, how does $Feature_type get assigned?
Since I'll need to do
<sql "insert into features values (counter, $Item_id, $Feature_type, $Feature_name)">
</sql>
I can't have $Feature_type with value "product product brand".
Thanks.
xml
Posted: Wed Jun 06, 2001 6:00 pm
by mark
Repeated items are collected into the field with a newline between each. If you want to denormalize that into multiple records you can use <split> on $Feature_type and $Feature_name and loop over those to insert.