本文介绍了将Xpath从java转换为c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我需要你的帮助。

1.我不确定这段代码是什么

2.我怎么重写这个是c#,因为c#库中不存在XpathApi。

hey guys pls I need your help.
1. I am not really sure what this piece of code does
2. how do I rewrite this is c#, since XpathApi does not exist in the c# library.

Node objRecorNode;
Node objCurrentField = null;


public boolean setToFirstRecord() {
  try {
       objCurrentField = XPathAPI.selectSingleNode(objRecordNode,"./FIELD");
       if(objCurrentField==null)
       return false;
    else
       return true;
      } catch(Exception e) {
      System.out.println("Error in setToFirstRecord of RecordObject "  + e.getMessage());
       return false;
    }

}



感谢您的帮助,非常感谢


thanks for the help, very greatful

推荐答案

XmlNode objRecordNode;
XmlNode objCurrentField;

public bool SetToFirstRecord()
{
   try {
      objCurrentField = objRecordNode.SelectSingleNode("./FIELD");
      return (objCurrentField != null);
   }
   catch (Exception ex) {
      Debug.WriteLine(string.Format("Error in setToFirstRecord of RecordObject {0}", e.Message()));
      return false;
   }
}





(粗略因为我不经常使用XML文档;但我希望你有这个想法)



[/ EDIT]



(rough because I do not use XML documents so often ; but I hope you got the idea)

[/EDIT]


这篇关于将Xpath从java转换为c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:18
查看更多