Hello,
I would like to extract Field values from Word files (docx) to add the values to the library item afterwards. I am struggling with the extraction of the values.
Which way would you suggest is the best way?
My first approach was to
- extract the xml file from the docx
- Compose action with an xpath expression
Unfortunately I could not succeed and received the error below.
My Expression:
xpath(xml(body('Get_file_content_using_path')), '//w:sdt[w:sdtPr/w:alias[@w:val="ManufacturerName"]]/w:sdtContent/w:r/w:t')
XML Code:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16du="http://schemas.microsoft.com/office/word/2023/wordml/word16du" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16sdtfl="http://schemas.microsoft.com/office/word/2024/wordml/sdtformatlock" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh w16sdtfl w16du wp14">
<w:body>
<w:p w14:paraId="43A9B8E4" w14:textId="1B1BD7E0" w:rsidR="004A795C" w:rsidRDefault="00361E50">
<w:r>
<w:t>Test Document</w:t>
</w:r>
</w:p>
<w:p w14:paraId="18FE5C1F" w14:textId="77777777" w:rsidR="00361E50" w:rsidRDefault="00361E50"/>
<w:sdt>
<w:sdtPr>
<w:alias w:val="PlatformType"/>
<w:tag w:val="PlatformType"/>
<w:id w:val="1002545856"/>
<w:placeholder>
<w:docPart w:val="DefaultPlaceholder_-1854013440"/>
</w:placeholder>
<w:text/>
</w:sdtPr>
<w:sdtContent>
<w:p w14:paraId="106D80BE" w14:textId="30EDD090" w:rsidR="00361E50" w:rsidRDefault="00361E50">
<w:r>
<w:t>V162</w:t>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
<w:p w14:paraId="1AC54C5B" w14:textId="77777777" w:rsidR="00361E50" w:rsidRDefault="00361E50"/>
<w:sdt>
<w:sdtPr>
<w:rPr>
<w:lang w:val="en-US"/>
</w:rPr>
<w:alias w:val="ManufacturerName"/>
<w:tag w:val="ManufacturerName"/>
<w:id w:val="-189067879"/>
<w:placeholder>
<w:docPart w:val="DefaultPlaceholder_-1854013440"/>
</w:placeholder>
<w:text/>
</w:sdtPr>
<w:sdtContent>
<w:p w14:paraId="021BA8E1" w14:textId="2599200E" w:rsidR="00361E50" w:rsidRPr="00361E50" w:rsidRDefault="00361E50">
<w:pPr>
<w:rPr>
<w:lang w:val="en-US"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val="en-US"/>
</w:rPr>
<w:t>Vestas</w:t>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
<w:sectPr w:rsidR="00361E50" w:rsidRPr="00361E50" w:rsidSect="00836980">
<w:footerReference w:type="even" r:id="rId6"/>
<w:footerReference w:type="default" r:id="rId7"/>
<w:footerReference w:type="first" r:id="rId8"/>
<w:pgSz w:w="11906" w:h="16838"/>
<w:pgMar w:top="1417" w:right="1417" w:bottom="1134" w:left="1417" w:header="708" w:footer="708" w:gutter="0"/>
<w:cols w:space="708"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>
Error message:
Action 'Compose01' failed: Unable to process template language expressions in action 'Compose01' inputs at line '0' and column '0': 'The template language function 'xml' expects one parameter: the string or object to be converted. The function was invoked with '2' parameter(s). Please see https://aka.ms/logicexpressions#xml for usage details.'.
Can somebody give me hint, if this way works at all and how I have to change the expression?
Thanks ahead,
Felix