我被要求在C#中执行以下操作:
/**
* 1. Create a MultipartPostMethod
* 2. Construct the web URL to connect to the SDP Server
* 3. Add the filename to be attached as a parameter to the MultipartPostMethod with parameter name "filename"
* 4. Execute the MultipartPostMethod
* 5. Receive and process the response as required
* /
Run Code Online (Sandbox Code Playgroud)
我写了一些没有错误的代码,但是没有附加文件.
有人可以查看我的C#代码,看看我是否错误地编写了代码?
这是我的代码:
var client = new HttpClient();
const string weblinkUrl = "http://testserver.com/attach?";
var method = new MultipartFormDataContent();
const string fileName = "C:\file.txt";
var streamContent = new …Run Code Online (Sandbox Code Playgroud) 我可以帮忙从HTML文档中获取价值吗?
这是文档内容:
<html>
<head>
<style>body, table, input, select, textarea, button { font: normal 1em Verdana, Sans-Serif; } body { font-size: 0.8em; } a { color:#336600; } b { color:#003300; }.header {font-family: verdana; font-size: 15px; color:#003300; font-weight:bold;}.back {background-color:#DBF0DB;}.back2 {background-color:#009933;}
</style>
</head>
<body>
<table border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td colspan="2" class="header">#827216</td>
</tr>
</table>
<body>
</html>
Run Code Online (Sandbox Code Playgroud)
我想检索#827216值。
这是我正在使用的代码,无法正常工作:
hdoc.LoadHtml(FileContents);
var xID = hdoc.DocumentNode.SelectNodes("/html/body/table/tr/");
Run Code Online (Sandbox Code Playgroud)
这是错误:
表达式必须计算为节点集
我在使用 jQuery Step Wizard 插件动态创建一些步骤时遇到了一些麻烦。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.10.2.min.js"><\/script>')</script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js" type="text/javascript"></script>
<script>$.mobile || document.write('<script src="js/jquery.mobile-1.4.0.min.js"><\/script>')</script>
<script src="scripts/libs/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<script src="scripts/libs/jquery.steps-1.0.4.js"></script>
<script src="scripts/libs/jquery.validate-1.11.1.min.js"></script>
</head>
<body>
<script>
$(document).ready(function () {
$("#wizard").steps();
var wizard = $("#wizard").steps();
wizard.steps("add", {
title: "HTML code",
content: "This is a test"
});
wizard.steps("add", {
title: "HTML code2",
content: "This is a test2"
});
});
</script>
<div id="wizard"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
运行此页面时,网页上显示的只是“下一个”和“上一个”,但根本没有任何步骤。
我得到的控制台错误是这样的:
SCRIPT5022:缺少一个或多个相应的步骤标题。jquery.steps-1.0.4.js,第 1252 行字符 5
我可以得到一些帮助来完成这项工作吗?
提前致谢
我正在使用C#并有一些字符串数据如下:
我已将其拆分为一个数组,以便我可以逐行查看上述每个项目.当逐行查看此代码时,我可以请一些帮助来获取每个th和/ th标签之间的内容吗?
在C#中,如何使用LINQ从XML文件中选择值?
这是我的XML文件:
<?xml version="1.0" encoding="utf-8"?>
<Level1>
<Level2>
<Value1>This-is-value-1</Value1>
<Value2>This-is-value-2</Value2>
<Value3>This-is-value-3</Value3>
<Value4>This-is-value-4</Value4>
</Level2>
</Level1>
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止的代码:
var doc = XDocument.Load(filename);
var values = from lv1 in doc.Descendants("level1")
from lvl2 in lv1.Descendants("Level2")
select new {
Value1 = lv1.Attribute("Value1").Value,
Value2 = lv1.Descendants("Value2").Value,
Value3 = lv1.Descendants("Value3").Value,
Value4 = lv1.Descendants("Value4").Value,
};
Run Code Online (Sandbox Code Playgroud)
我想要检索以下值:
我可以请一些帮助让这个工作吗?
编辑
抱歉,我想补充说我想将值放在本地字段中.
以下是字段名称:
string Value1;
string Value2;
string Value3;
string Value4;
Run Code Online (Sandbox Code Playgroud)
我可以帮助将LINQ语句中的值放入本地字段吗?
c# ×4
html ×2
document ×1
filestream ×1
find ×1
httpclient ×1
javascript ×1
jquery ×1
jquery-steps ×1
linq ×1
linq-to-xml ×1
nodes ×1
post ×1
search ×1
select ×1
string ×1
xml ×1