pptx 파일을 구문 분석 중이므로 문제가 발생했습니다. 나는 sldMasterId
태그의 r:id
속성 값을 얻을 필요가네임 스페이스를 사용하여 XML 특성 값 가져 오기
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<p:sldMasterIdLst>
<p:sldMasterId id="2147483648" r:id="rId2"/>
</p:sldMasterIdLst>
<p:sldIdLst>
<p:sldId id="256" r:id="rId3"/>
</p:sldIdLst>
<p:sldSz cx="10080625" cy="7559675"/>
<p:notesSz cx="7772400" cy="10058400"/>
</p:presentation>
:이 소스 XML의 샘플입니다.
doc = Nokogiri::XML(path_to_pptx)
doc.xpath('p:presentation/p:sldMasterIdLst/p:sldMasterId').attr('id').value
반환 2147483648
하지만 나는 r:id
속성 값 인 rId2
이 필요합니다.
attribute_with_ns(name, namespace)
방법을 찾았지만,
doc.xpath('p:presentation/p:sldMasterIdLst/p:sldMasterId').attribute_with_ns('id', 'r')
반환 전무.