Board logo

标题: [问题求助] [已解决]powershell 中 getElementById不起作用 [打印本页]

作者: yiwuyun    时间: 2017-4-10 12:36     标题: [已解决]powershell 中 getElementById不起作用

本帖最后由 yiwuyun 于 2017-4-10 14:01 编辑
  1. if ($true){}# == ($true){}# goto ___yiwuyun
  2. <#BeginBatOperation#
  3. :___yiwuyun
  4. @echo off&setlocal&cls
  5. (echo $yiwuyun_fileName="%~f0"&echo $strPath="%~dp0"&type "%~f0")|powershell -command -
  6. pause
  7. exit/b 0
  8. #EndBatOperation#>
  9. <#StartPowerShell#>
  10. $xml=@"
  11. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  12. <root>
  13. <bat001 name="bat1" id="bat1">
  14. data
  15. </bat001>
  16. </root>
  17. "@
  18. $doc=New-Object -TypeName System.Xml.XmlDocument;
  19. $doc.LoadXml($xml);
  20. ###$doc.GetElementById("bat1");  这一句不起作用
  21. $doc.GetElementsByTagName("bat001");### 这一句正常
  22. <#EndPowerShell#>
复制代码
有朋友遇到过吗?不会是我写法错了吧。
作者: pcl_test    时间: 2017-4-10 12:56

https://msdn.microsoft.com/en-us ... getelementbyid.aspx
  1. Note
  2. The DOM implementation must have information which defines which attributes are of type ID. Although attributes of type ID can be defined in either XSD schemas or DTDs, this version of the product only supports those defined in DTDs. Attributes with the name "ID" are not of type ID unless so defined in the DTD. Implementations where it is unknown whether the attributes are of type ID are expected to return null.
复制代码

作者: yiwuyun    时间: 2017-4-10 14:00

many thanks.




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2