Home > Software design >  XPath - Parsing inside Attribute Values
XPath - Parsing inside Attribute Values

Time:01-25

The question is probably very easy for most to answer, since I am a complete beginner.

I have an attribute value in an XML that contains several pieces of information that are separated by a separator. Now I want to read only one specific information out of the attribute.

Heres an Example:

<Product DueDate="" FinishedTrimHeight="" FinishedTrimWidth="" ID="" Name="" Notes="1000 | ST | 170ma | 4/4 | 135ma | 4/4 | F-EB-4S DBK-16S | BNDLI | SaddleStitch | Links | Sped" RequiredQuantity="" TextContentFile="" Type=""> </Product>

I want to extract only "170ma" out of the Attribute in this case.

Thanks in advance!

CodePudding user response:

Try something like:

tokenize(Product/@Notes, ' \| ')[3]

I say "something like" because you did not post your attempt and it's not clear from which context you need this.

Requires XSLT 2.0 or higher.

  •  Tags:  
  • Related