import {check,parse,textFile,xmlFile,put,done,text,tableCD,xhr} from './xml-browser.js';
try{
const frame=document.querySelector('#styled');let title;for(let i=0;i<500;i++){title=frame.contentDocument?.getElementsByTagName('TITLE')[0];if(title&&frame.contentWindow.getComputedStyle(title).color==='rgb(37, 99, 235)')break;await new Promise(r=>setTimeout(r,10))}check(title,'styled XML loaded');const style=frame.contentWindow.getComputedStyle(title);check(style.display==='block'&&style.color==='rgb(37, 99, 235)'&&title.getBoundingClientRect().height>0,'actual XML CSS rendering');check(frame.contentDocument.getElementsByTagName('CD').length===3,'all three records');done({actual_TITLE_display:style.display,color:style.color,height:title.getBoundingClientRect().height,records:3});
}catch(error){window.mbskyError=String(error);document.querySelector('#status').textContent='运行失败:'+String(error)}
本例需在 Windows / Python3.12+lxml6.1.3 / Edge156 / 自有本地HTTP,PHP为独立附例 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Windows / Python3.12+lxml6.1.3 / Edge156 / 自有本地HTTP,PHP为独立附例
入口文件:projects/xml-lab/xml-display.js
预期结果与验证条件观察提示
- XML iframe确有3条CD,TITLE真实display:block/颜色rgb(37,99,235)/可见高度。
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联29章) · 含当前章节或实例 · mbskycom202611a539.zip