xml.SelectSingleNode 的问题

qq_27638253 2017-11-30 11:29:03


XmlDocument xml = new XmlDocument();
xml.Load(path);//0827

XmlNode widthnode = xml.SelectSingleNode("/ThermalLabel/Width");
XmlElement widthxe = (XmlElement)widthnode;

XmlNode heightnode = xml.SelectSingleNode("/ThermalLabel/Height");
XmlElement heightxe = (XmlElement)heightnode;

XmlNodeList nodelist = xml.SelectNodes("/ThermalLabel/Items"); 可以获取 items 的节点

为啥 heightnode widthnode 返回都是空呢
...全文
93 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2017-11-30
  • 打赏
  • 举报
回复
你查询的是节点,而实例的 XML 只有属性
qq_27638253 2017-11-30
  • 打赏
  • 举报
回复
我要送分谁来
qq_27638253 2017-11-30
  • 打赏
  • 举报
回复
解决了,只是属性,不是节点
qq_27638253 2017-11-30
  • 打赏
  • 举报
回复
<ThermalLabel Version="7.0" Width="70" Height="25" GapLength="0" MarkLength="0" OffsetLength="0" UnitType="Mm" LabelsPerRow="1" LabelsHorizontalGapLength="0" IsContinuous="False" PrintSpeed="" PrintMirror="False" CutAfterPrinting="False"> <Items> <TextItem Name="" X="2.7209" Y="10.1744" DataField="" DataFieldFormatString="" CacheItemId="" Comments="" Tag="" Width="25.8733" Height="12.5291" Text="yyyyyy" Font="黑体,20,True,False,False,False,Point,,,False,90,,CP850"/> </Items> </ThermalLabel>

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧