Hello,

xml2node works fine and elegant.
But I want to add multiple files in a filefield (with unlimited files).
How does one specify that?

The furthest I came was below, but the second det2 replaces the first one, it doesn't add, so my filefield only has 1 file.

I am not an XML expert, maybe overlooked something basic?
Any suggestions how to do that?

sites/default/files/upload/det1.jpg
det1.jpg

sites/default/files/upload/det2.jpg
det2.jpg

Comments

Anonymous’s picture

hi,

You can add the the field-element multiple times with different files:


        <article type="contenttype">
		<title type="field">A sample Title 2</title>
		<field_lead type="field">
			<value>This is my lead text.</value>
			<format>1</format>
		</field_lead>
		<field_record_id type="field">
			<value>2</value>
		</field_record_id>
		<field_file type="field">
			<filepath>sites/default/files/upload/det1.jpg</filepath>
			<filename>det1.jpg</filename>
			<data>
				<title>the files title</title>
				<description>the files description</description>
				<alt>the files alt tag</alt>
			</data>
		</field_file>
                <field_file type="field">
			<filepath>sites/default/files/upload/det2.jpg</filepath>
			<filename>det2.jpg</filename>
			<data>
				<title>the files title</title>
				<description>the files description</description>
				<alt>the files alt tag</alt>
			</data>
		</field_file>
	</article>

Let me know if that works for you.

ecj’s picture

The problem is that this ends up with only det2.jpg in the file field.

If this whole det2 (second file in the unlimited file fields) declaration is removed, then det1.jpg turns up.
So I guess that with this syntax, first det1 is inserted, then overwritten by det2.

I tried something with inserting item... item (excuse me for missing the brackets). But that doesn't work either.