xml

Post Reply
jlin
Posts: 27
Joined: Fri Apr 06, 2001 4:03 pm

xml

Post 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.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

xml

Post by mark »

I'm not sure what you're asking.
Also feature_type is not the same as feature/type.
jlin
Posts: 27
Joined: Fri Apr 06, 2001 4:03 pm

xml

Post 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.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

xml

Post 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.
Post Reply