Closed (fixed)
Project:
Feeds XML Parser
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 May 2010 at 12:36 UTC
Updated:
10 Jun 2010 at 05:55 UTC
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
Comment #1
mokko commentedI 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.
Comment #2
chrisirhc commentedmokko I think you meant:
object/objecttyp/value/@valuetypIf 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
tag.
Please read up about XPath at:
http://www.w3schools.com/xpath/
Comment #3
mokko commentedThanks, 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.
Comment #4
tfranz commentedHi 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?
Comment #5
chrisirhc commentedHi 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
//customerfor 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.
Comment #6
mokko commentedAs 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?
Comment #7
chrisirhc commented