I succeeded in mapping the example.xml of this module, but how to map a nested XML-structure like this one:

<?xml version="1.0" encoding="ISO-8859-1"?>
<master>
	<customer>
	
		<product>
			<object>
				<objecttyp>
					<value valuetyp="special"/>
				</objecttyp>
			</object>
			<tech>
				<id>111</id>
			</tech>
		</product>
		
		<product>
			<object>
				<objecttyp>
					<value valuetyp="normal"/>
				</objecttyp>
			</object>
			<tech>
				<id>222</id>
			</tech>
		</product>	
				
	</customer>
</master>

id => GUID doesn't work, nor does
////id => GUID
or
master/customer/product/tech/id => GUID

And how to get value valuetyp="normal"?

Thank you for any hint or help,

Tobias

Comments

mokko’s picture

I am trying to figure out similar issues.

I am using http://github.com/chrisirhc/feeds_xmlparser

What xpath did you try? It seems it should be

/master/customer/product
or
//product

From the experiments I did myself it seems that the parser can parse hierarchical xml structures, my question is how to display this in cck.

If I am correct you should be able to map something like

object/objecttyp/@special CCK:objecttyp
tech/id --> CCK:tech_id

this would flatten your datastructure displaying it non-hierarchical as cck fields, but should work.

If you want to preserve hierarchical relationships in Drupal, I wonder whether we want to use the data module (http://drupal.org/project/data) and how to use it. That's where I stopped last weekend.

chrisirhc’s picture

mokko I think you meant:
object/objecttyp/value/@valuetyp

If you wanted to get those that are of a certain valuetype you could do something like:
object/objecttyp/value[@valuetyp='normal']

It still seems more like a question of how to do something in XPath..
We could probably include some additional examples though. I'm open to that.
Please clarify if it isn't the case, and remember to place all code within the

<code></code>

tag.

Please read up about XPath at:
http://www.w3schools.com/xpath/

mokko’s picture

Thanks, chrisirhc!

I come to terms with xpath, I justed wanted to give a hint to tfranz anyways.

I posted a couple of observations in your wiki, since you mentioned that you were not the maintainer of this module. However, that the weekend is almost over and I have to continue with different things, so it'll take me some time to respond again.

tfranz’s picture

Hi mokko,

thanks for your reply!

I tried:
XPath: //customer
product//tech//id => GUID
product//tech//name => Title

XPath: customer
product/tech/id => GUID
product/tech/name => Title

... and some other ... unfortunately it didn't help ...

But it seems i'm not alone:
http://drupal.org/node/631104#comment-3035740

Maybe this problem should be discussed there?

chrisirhc’s picture

Hi there, could you attach the xml document in question? You could remove any sensitive data (even just 1 or 2 entries will do, not the whole document).

Probably need to take a look at it to see.

If you use //customer for the XPath, you're only going to get one entry in the above sample.

Another thing, try using tech/id => GUID, tech/name => Title (if that doesn't work, add // before them)
I'm thinking due to the way SimpleXML works, the root element is already the product element. I maybe wrong.

mokko’s picture

As much as I recall tfranz's last comment (125) on http://drupal.org/node/631104 he solved his problem in the meantime. Then he gave this as the solution:


Xpath: //customer//product
//tech//name => Title
//tech//id => GUID

Close this issue?

chrisirhc’s picture

Status: Active » Closed (fixed)