我在 JavaScript 中查看了将字符串转换为 XML 文档,但在我的情况下找不到解决方案,有人可以帮助我吗?
我有一个像下面这样的字符串,我想将它转换为 XML 对象,我该怎么做?
<list>
<Response>
<cfgId>280</cfgId>
<recommendations><Rule>
<name>simple rule</name>
<category>none</category>
<severity>warning</severity>
<ruleEvalResult>true</ruleEvalResult>
<actionResult> Current value of maxfilesperproc is 32
increase it to 1024</actionResult>
</Rule></recommendations>
</Response>
</list>
Run Code Online (Sandbox Code Playgroud)
上述xml的可读版本
<list>
<Response>
<cfgId>280</cfgId>
<recommendations>
<Rule> <name>simple rule</name> <category>none</category> <severity>warning</severity> <ruleEvalResult>true</ruleEvalResult> <actionResult>Current value of maxfilesperproc is 32
increase it to 1024</actionResult> </Rule>
</recommendations>
</Response>
</list>
Run Code Online (Sandbox Code Playgroud)
更新,这是我尝试过的。
var xml;
$.post("/csm/rules.action",
{ sessiontoken: sessiontoken,
cfgid: cfgid},
function(xmldata)
{
xml=$(xmldata);
}
);
var htmlTable = $('<table></table>');
$(xml).find('Response').each(function(){
var …
Run Code Online (Sandbox Code Playgroud) 我有一个showlink的自定义格式化程序,下面打开新的页面是代码和屏幕截图
{name:'cfgName',index:'cfgName', width:90, align:"left", formatter: 'showlink', formatoptions:
{
baseLinkUrl:'javascript:',
showAction: "goToViewAllPage('",
addParam: "');"
}},
Run Code Online (Sandbox Code Playgroud)
我想要的是如果Last Updated time
和今天的日期的差异超过10天它应该warning
在之前显示图像Name
我编写了下面的函数来计算2个日期的差异,这里是演示,但我需要帮助放置showlink名称前面的图像,如果no of days count
在网格中> 10
function diffOf2Dates(todaysDate,configDate)
{
/*var udate="2011-08-18 11:49:01.0";
var configDate=new Date(udate);*/
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var firstDate = todaysDate; // Todays date
var secondDate = new Date(configDate);
var diffDays = Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay));
console.info(firstDate+", "+secondDate);
//console.info(Math.ceil(diffDays));
return Math.ceil(diffDays);
}
Run Code Online (Sandbox Code Playgroud)
这是我的jqGrid代码
var grid = …
Run Code Online (Sandbox Code Playgroud) 我正在使用Groovy在我的Linux机器上执行命令并取回输出,但我无法以|
某种方式使用管道(我认为)或者它可能不等待命令完成.
我的代码中有什么问题或者我错过了什么?
我的呼叫功能:
def test()
{
String result="N"
HashMap<String,String> params = IntermediateResults.get("userparams")
Map env=AppContext.get(AppCtxProperties.environmentVariables)
def fClass = new GroovyClassLoader().parseClass( new File( 'plugins/infa9/Infa9CommandExecUtil.groovy' ) )
List<String> frows=["uname -a",
"uname -a | awk '{print\$2}'",
"uname -a | cut -d ' ' -f 2"]
List<String> resultRows = fClass.newInstance().fetchCommandOutput( params, env, frows )
return result
}
Run Code Online (Sandbox Code Playgroud)
Infa9CommandExecUtil.groovy
文件内容(更新:添加exitVal println):
package infa9
import java.io.BufferedReader;
public class Infa9CommandExecUtil {
StringBuffer result
public Infa9CommandExecUtil() {
result = new StringBuffer()
}
public List<String> fetchCommandOutput( Map<String,String> params, …
Run Code Online (Sandbox Code Playgroud) 我正在使用JavaMail API 1.4.4发送邮件.到目前为止,我能够发送邮件,但实际上我需要发送HTML内容,以便在收到邮件时处理html标签.
示例:如果我的消息中有表格代码,则应处理html代码并将其显示在邮件中
我的守则
import java.io.File;
import java.util.*
import javax.mail.*
import javax.mail.internet.*
import javax.activation.*
class Mail {
static void sendMail(mailProp) {
// Get system properties
Properties properties = System.getProperties()
// Setup mail server
properties.setProperty("mail.smtp.host", mailProp.host)
// Get the default Session object.
Session session = Session.getDefaultInstance(properties)
try {
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session)
// Set From: header field of the header.
message.setFrom(new InternetAddress(mailProp.from))
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO,new InternetAddress(mailProp.to))
// …
Run Code Online (Sandbox Code Playgroud) 我有下面的Json(wf.json)
{
"workflow":{
"template":"Analysis1",
"start":{
"instance":"HDA_run1",
"user":"symtest",
"date":"3-Mar-2012",
"timestamp":"1330948220475"
},
"host":{
"name":"bartla",
"user":"symtest1",
"password":"symtest1",
"installpath":"",
"product":""
},
"javadump":{
"pid":"8989",
"corefilename":"",
"heapdump":"",
"stack":"",
"JAVA_HOME":""
},
"mat":{
},
"email":{
"to":"ars@gmail.com",
"subject":"",
"message":""
},
"end":{
}
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,有7个项目(或主标题内的子标题workflow
).在每个项目下,它可以有另一组属性,例如:email (item)
有3个属性("name":"value")
.
因此,基于我需要能够(Text)
在Flex 3 UI中创建控件的属性数量.
我读到这里是actionjson比快5-6x 的as3corelib,但我无法找到任何示例代码它.actionjson doc说它的功能与corelib相同,所以我甚至试过import com.adobe.serialization.json.JSON; JSON.decode(rawData)
但是找不到它JSON
.
以下是我的代码
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" minWidth="955" minHeight="600"
creationComplete="service.send()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
private function onJSONLoad(event:ResultEvent):void
{
//get the …
Run Code Online (Sandbox Code Playgroud) 我有一个要求,我根据JSON响应动态创建单选按钮.到目前为止,我所做的Chrome和Firefox的作品,但给Object doesn't support this property or method
上if(subItem[1].indexOf(",") >= 0)
线
我的代码
$("#sList").live("change", function(){
var currentService=this.value;
var c1Svc=[];
var c2Svc=[];
if(absP.length==2)
{
$.each(compareServiceData,function(i,item){
if(currentService==item[0])
{
var configCount=0;
$.each(item[1],function(j,subItem){
var temp=subItem[1];
/*The JSON response contains List of Lists, so here if it contains a list it will be separated by "," so split it and store in a array, else directly store in a array*/
if(subItem[1].indexOf(",") >= 0)
{
var tList=temp.split(",");
$.each(tList,function(k,val){
if(configCount==0)
{
c1Svc.push(val);
}
else
{
c2Svc.push(val); …
Run Code Online (Sandbox Code Playgroud) html javascript jquery internet-explorer internet-explorer-8
我有这个morris.js酒吧有多个酒吧,我想改变酒吧的宽度或在持续时间之间腾出空间.从下面的图像有一种方法可以提供更多的空间Feb
March
和/ April
或有没有办法调整条宽?
这是我的代码
Morris.Bar({
element: 'morris-chart-bar',
data: [
{ y: 'Feb', a: 75, b: 60, c: 5, d: 50 },
{ y: 'March', a: 180, b: 220, c: 140, d: 160 },
{ y: 'April', a: 300, b: 340, c: 350, d: 270 }
],
xkey: 'y',
ykeys: ['a', 'b', 'c', 'd'],
labels: ['A', 'B', 'C', 'D'],
barColors: ['#0B62A4','#f75b68','#4DA74D','#646464'],
hideHover: 'auto'
});
Run Code Online (Sandbox Code Playgroud)
我正在使用Apache Http客户端来使用ElasticSearch Rest Api,但我总是得到HTTP错误代码为200.请帮忙
Java代码
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.util.Scanner;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
public class ApacheHttpClientPost {
public static void main(String[] args) {
String path="C:\\Tools\\ElasticSearchApi\\javadoc.txt", filecontent="";
ApacheHttpClientPost apacheHttpClientPost = new ApacheHttpClientPost();
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost("http://localhost:9200/versioneg/message/_percolate");
filecontent=apacheHttpClientPost.readFileContent(path);
System.out.println(filecontent);
StringEntity input = new StringEntity(filecontent);
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse response = httpClient.execute(postRequest);
if (response.getStatusLine().getStatusCode() != 201) {
throw new RuntimeException("Failed : HTTP error code …
Run Code Online (Sandbox Code Playgroud) java httpclient elasticsearch apache-commons-httpclient apache-httpclient-4.x
我正在尝试向 TLS 服务器发布默认和自定义密钥库。在执行执行时获得 CloseableHttpClient 实例后
CloseableHttpResponse response1 = client.execute(postMethod);
Run Code Online (Sandbox Code Playgroud)
这给了我javax.net.ssl.SSLPeerUnverifiedException: Certificate for <hostname.domain.com> doesn't match any of the subject alternative names: []
上面一行的例外。
下面是我准备客户端实例的类
public class ClientelUtil {
public static CloseableHttpClient getHttpClient(String scheme,SSLContext sslContext) {
HttpClientBuilder clientBuilder = HttpClients.custom();
CloseableHttpClient client = null;
if ("https".equalsIgnoreCase(scheme)) {
SSLConnectionSocketFactory sFactory = new SSLConnectionSocketFactory(sslContext);
final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", new PlainConnectionSocketFactory()).register("https", sFactory).build();
final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
clientBuilder = HttpClients.custom().setSSLSocketFactory(sFactory)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setConnectionManager(cm);
}
client = clientBuilder.build();
return client;
}
public …
Run Code Online (Sandbox Code Playgroud) 我有key value
一对对.是否可以精确匹配值,key
然后检查它的value
范围值?
示例:在下面的doc中oracle_props
是一个包含名称,值对的数组.我需要检查它是否有"oracle_cursors"
密钥,然后检查它的值是否小于1000.
GET /eg/message/_percolate
{
"doc": {
"client": {
"name": "Athena",
"version": 1,
"db": {
"@type": "Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 64bit",
"oracle_props": [
{
"@name": "open_cursors",
"@value": 4000
},
{
"@name": "USER_ROLE_PRIVS_COUNT",
"@value": 1
},
{
"@name": "CREATE_PERMISSION",
"@value": "Y"
}
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
下面是我的过滤器.
我还需要检查以下内容,以便它返回3
作为我的结果
1和2是和操作,并且3或4中的任何一个满足它应该得到3
.我需要第4点的帮助,下面是我的查询.如果有更好的方法,请建议.
PUT /eg/.percolator/3
{
"query": {
"filtered": { …
Run Code Online (Sandbox Code Playgroud) java ×4
jquery ×4
javascript ×3
groovy ×2
json ×2
actionscript ×1
apache-flex ×1
css ×1
flex3 ×1
html ×1
httpclient ×1
jakarta-mail ×1
jqgrid ×1
morris.js ×1
ssl ×1