in reply to XML Parsing and Xpath confusion
Think of a [] in an XPath as similar to a WHERE clause in an SQL statement, which is to say a filter.
/ADI/Asset/Asset/Metadata suggests that you want some asset metadata nodes. I'm going to assume that's correct for now.
But we only want metadata nodes where AMS/@Asset_Class equals poster. This is a filter.
/ADI/Asset/Asset/Metadata[ AMS/@Asset_Class = "poster" ]
Since this is a nested collection of assets, maybe you want to look any depth.
//Asset/Metadata[ AMS/@Asset_Class = "poster" ]
With the above, the asset name would be found at relative path AMS/@Asset_name. App_Data would return rows of metadata.
Is the asset metadata really what you want, though? If you wanted the whole asset instead of just its metadata (e.g. if you wanted to access the asset's content), you should use one of the following instead:
/ADI/Asset/Asset[ Metadata/AMS/@Asset_Class = "poster" ]
//Asset[ Metadata/AMS/@Asset_Class = "poster" ]
With these, the asset name would be found at relative path Metadata/AMS/@Asset_name. Metadata/App_Data would return rows of metadata. Content/@Value would return the poster image.
As a side note, an example of multiple [] in an XPath,
//Asset[ AMS/@Asset_Class = "package" and AMS/@Asset_Name = "some_pack +age" ]/Asset[ Metadata/AMS/@Asset_Class = "poster" ]
This would return the poster asset for a specific package.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: XML Parsing and Xpath confusion
by naChoZ (Curate) on Jul 08, 2024 at 14:16 UTC |