Home > Back-end >  FFProbe XML XPath
FFProbe XML XPath

Time:03-11

I'm stuck trying to use XPath and pull the variables out of this XML provided by FFProbe. /ffprobe/streams/codec_type

 <?xml version="1.0" encoding="UTF-8"?> 
    <ffprobe> 
        <streams> 
            <stream index="0" codec_name="mpeg2video" codec_long_name="MPEG-2 video"/>` 
            </stream>
        </streams>
    </ffprobe>

CodePudding user response:

Your XPath,

/ffprobe/streams/codec_type

selects codec_type elements with the specified heritage, yet your XML,

<?xml version="1.0" encoding="UTF-8"?> 
<ffprobe> 
    <streams> 
        <stream index="0" codec_name="mpeg2video" codec_long_name="MPEG-2 video"/>` 
        </stream>
    </streams>
</ffprobe>
  1. has no such element, and
  2. is not well-formed since it has an extraneous </stream> closing tag following a self-closed <stream/> tag.
  • Related