对于Towxml感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于10wx.showToast消息提示框wx.showModal模态对话框、C#xml读xml、写xml、Xpath、Xmlt
对于Towxml感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于10wx.showToast消息提示框 wx.showModal模态对话框、C# xml 读xml、写xml、Xpath、Xml to Linq、xml添加节点 xml修改节点、How to convert XML String into XML document、How to convert XML to Android Binary XML的宝贵知识。
本文目录一览:- Towxml
- 10wx.showToast消息提示框 wx.showModal模态对话框
- C# xml 读xml、写xml、Xpath、Xml to Linq、xml添加节点 xml修改节点
- How to convert XML String into XML document
- How to convert XML to Android Binary XML
Towxml
Towxml 介绍
Towxml 是一个可将html、Markdown转为微信小程序WXML(WeiXin MarkuP Language)的渲染库。
用于解决在微信小程序中Markdown、html不能直接渲染的问题。
特色
可控制的音频播放器(可自行调节样式,解决原生audio在部分iPhone上不能自动播放的情况)
支持代码语法高亮
支持emoji表情
支持上标、下标、下划线、删除线、表格、视频、图片(几乎所有html元素)……
支持typographer字符替换
多主题动态支持
极致的中文排版优化
Markdown TodoList
支持事件绑定(这样允许自行扩展功能哟,例如:点击页面中的某个元素,更新当前页面内容等...)
前后端支持
音频播放器播放状态设定为每5秒更新一次,否则内容过多会导致性能下降
网站地址:https://github.com/sbfkcel/towxml
GitHub:https://github.com/sbfkcel/towxml
网站描述:HTML、Markdown转微信小程序WXML渲染库
Towxml官方网站
官方网站:https://github.com/sbfkcel/towxml
如果觉得小编网站内容还不错,欢迎将小编网站 推荐给程序员好友。
10wx.showToast消息提示框 wx.showModal模态对话框
1==》wx.showToast 弹出层 在界面交互中 显示消息提示框
它是一个消失提示框 提示用户成功 或者失败等消息
<button size=''mini'' bindtap=''hanleShowToasr''>弹出层</button>
hanleShowToasr(){
wx.showToast({
title: ''成功了'',
duration:2000, //2s后消失
icon: ''none'',//去除小图标
})
},
2==》显示模态对话框 wx.showModal
它不仅有消失提示 还有确定和取消按钮
<button size=''mini'' bindtap=''getshowModal''>弹出层</button>
getshowModal(){
wx.showModal({
title: ''提示'',
content: ''这是一个模态弹窗'',
showCancel:false,//是否显示取消按钮 false 不显示
cancelText:"取消哦",//更改取消
confirmText:"吃工了",
success(res) {
if (res.confirm) {
console.log(''用户点击确定'')
} else if (res.cancel) {
console.log(''用户点击取消'')
}
}
})
},
C# xml 读xml、写xml、Xpath、Xml to Linq、xml添加节点 xml修改节点


#region 增、删、改操作==============================================
/// <summary>
/// 追加节点
/// </summary>
/// <param name="filePath">XML文档绝对路径</param>
/// <param name="xPath">范例: @"Skill/First/SkillItem"</param>
/// <param name="xmlNode">XmlNode节点</param>
/// <returns></returns>
public static bool AppendChild(string filePath, string xPath, XmlNode xmlNode)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(filePath);
XmlNode xn = doc.SelectSingleNode(xPath);
XmlNode n = doc.ImportNode(xmlNode, true);
xn.AppendChild(n);
doc.Save(filePath);
return true;
}
catch
{
return false;
}
}
/// <summary>
/// 从XML文档中读取节点追加到另一个XML文档中
/// </summary>
/// <param name="filePath">需要读取的XML文档绝对路径</param>
/// <param name="xPath">范例: @"Skill/First/SkillItem"</param>
/// <param name="toFilePath">被追加节点的XML文档绝对路径</param>
/// <param name="toXPath">范例: @"Skill/First/SkillItem"</param>
/// <returns></returns>
public static bool AppendChild(string filePath, string xPath, string toFilePath, string toXPath)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(toFilePath);
XmlNode xn = doc.SelectSingleNode(toXPath);
XmlNodeList xnList = ReadNodes(filePath, xPath);
if (xnList != null)
{
foreach (XmlElement xe in xnList)
{
XmlNode n = doc.ImportNode(xe, true);
xn.AppendChild(n);
}
doc.Save(toFilePath);
}
return true;
}
catch
{
return false;
}
}
/// <summary>
/// 修改节点的InnerText的值
/// </summary>
/// <param name="filePath">XML文件绝对路径</param>
/// <param name="xPath">范例: @"Skill/First/SkillItem"</param>
/// <param name="value">节点的值</param>
/// <returns></returns>
public static bool UpdateNodeInnerText(string filePath, string xPath, string value)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(filePath);
XmlNode xn = doc.SelectSingleNode(xPath);
XmlElement xe = (XmlElement)xn;
xe.InnerText = value;
doc.Save(filePath);
}
catch
{
return false;
}
return true;
}
/// <summary>
/// 读取XML文档
/// </summary>
/// <param name="filePath">XML文件绝对路径</param>
/// <returns></returns>
public static XmlDocument LoadXmlDoc(string filePath)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(filePath);
return doc;
}
catch
{
return null;
}
}
#endregion 增、删、改操作
#region 扩展方法===================================================
/// <summary>
/// 读取XML的所有子节点
/// </summary>
/// <param name="filePath">XML文件绝对路径</param>
/// <param name="xPath">范例: @"Skill/First/SkillItem"</param>
/// <returns></returns>
public static XmlNodeList ReadNodes(string filePath, string xPath)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(filePath);
XmlNode xn = doc.SelectSingleNode(xPath);
XmlNodeList xnList = xn.ChildNodes; //得到该节点的子节点
return xnList;
}
catch
{
return null;
}
}
#endregion 扩展方法


#region XDocument
//创建XDocument
XDocument xdoc2 = new XDocument();
XElement xel1= new XElement("AA",new XAttribute("mark","mark"));
xel1.Add(new XElement("AA1","2"));
xel1.Add(new XElement("AA2", "3"));
XElement xel2 = new XElement("AA");
xel2.Add(new XElement("AA1", "2"));
xel2.Add(new XElement("AA2", "3"));
xel2.Add(new XElement("AAA1", new XElement("AAA1","4")));
XElement xel = new XElement("A");
xel.Add(xel2, xel1);
xdoc2.Add(xel);
///循环XDocument
foreach (XElement xElement in xdoc2.Document.Root.Elements())
{
//根据节点名称获取值
string text=xElement.Element("AA1").Value;
//string text2 = xElement.Element("AAA1").Element("AAA1").Value;
//修改节点
xElement.SetElementValue("AA1", "AAA2");
//添加属性
xElement.SetAttributeValue("name", "name");
//设置值
xElement.Element("AA1").SetValue("");
}
#endregion
#region XmlDocument
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("D://Pro//EGP410_5//Test//XMLFile1.xml");
//循环XmlDocument
XmlNodeList xmlNode= xmlDoc.DocumentElement.ChildNodes;
foreach (XmlNode item in xmlNode)
{
}
//查询
string str = xmlDoc.DocumentElement.SelectSingleNode("DTrue").InnerText;
str = xmlDoc.DocumentElement.SelectSingleNode("/Result/DTrue").InnerText;
//修改
xmlDoc.DocumentElement.SelectSingleNode("DTrue").InnerText = "DTrue";
//获取属性
str = xmlDoc.DocumentElement.GetAttribute("mark");
//修改属性
xmlDoc.DocumentElement.SetAttribute("mark", "1543286313566");
//保存。
xmlDoc.Save("D://Pro//EGP410_5//Test//XMLFile1.xml");
#endregion
xml的读
XElement xele1 = XElement.Load(Path); //根据路径获取xml元素
XElement xele2 = XElement.Parse(""); //根据字符串获取xml元素
XmlDocument doc = new XmlDocument();
doc.LoadXml(xele1.ToString()); //根据字符串获取xml文档
doc.Load(Path); //根据路径获取xml文档
xml的取xpath
XDocument doc = XDocument.Load(Path);
XElement root = doc.Element("DATASET").Element("BUYER_NAME");
string text = xnode.InnerText; //获取值(方式一)
XmlNode node=doc2.SelectSingleNode("//DATASET/BUYER_NAME"); //获取单个xmlnode 不用循环
XmlNodeList nodes = doc.SelectNodes("//A/A01/A0101"); // 双斜线表示不从根目录取(获取多个xmlnode 所以要采用循环)
foreach (XmlNode de in nodes)
{
var dsd = de.InnerText; //获取值(方式二)
}
xml的写包括写入备注 (linq to xml)


public static void CreateXmlByLink()
{
XDocument xdoc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("提示"),
new XElement("root",
new XElement("A",
new XElement("A01",
new XElement("A0101", "货物A0101"),
new XComment("提示"),
new XAttribute("V1", "1"),
new XElement("A0102", "货物A0102"),
new XElement("A0103",
new XAttribute("V1", "1"),
new XElement("A010301",new XAttribute("V1", "1"), "货物A010301"),
new XElement("A010302", "货物A010302")
)
),
new XElement("A01",
new XElement("A0101", "货物A0101"),
new XElement("A0102", "货物A0102"),
new XElement("A0103",
new XElement("A010301", "货物A010301"),
new XElement("A010302", "货物A010302")
)
)
),
new XElement("B",
new XElement("A01",
new XElement("A0101", "货物A0101"),
new XElement("A0102", "货物A0102"),
new XElement("A0103",
new XElement("A010301", "货物A010301"),
new XElement("A010302", "货物A010302")
)
),
new XElement("A01",
new XElement("A0101", "货物A0101"),
new XElement("A0102", "货物A0102"),
new XElement("A0103",
new XElement("A010301", "货物A010301"),
new XElement("A010302", "货物A010302")
)
)
),
new XElement("C",
new XElement("A01",
new XElement("A0101", "货物A0101"),
new XElement("A0102", "货物A0102"),
new XElement("A0103",
new XElement("A010301", "货物A010301"),
new XElement("A010302", "货物A010302")
)
),
new XElement("A01",
new XElement("A0101", "货物A0101"),
new XElement("A0102", "货物A0102"),
new XElement("A0103",
new XElement("A010301", "货物A010301"),
new XElement("A010302", "货物A010302")
)
)
)
)
);
xdoc.Save(Path);
}
添加节点
XmlNode node= doc.SelectNodes("//A/A01/A0101")[0]; //修改/添加 路径下 的第一个节点
XmlElement no = doc.CreateElement("newNode");
no.InnerText = "新增节点1";
node.AppendChild(no); //新增
修改、删除xml节点
foreach (XmlNode item in node)
{
XmlElement xe = (XmlElement)item ;
if (xe.GetAttribute("A") == "A01")
{
xe.SetAttribute("A","A"); //修改
xe.Remove("A"); //修改
}
}
xml 映射到页面table(参照http://www.w3school.com.cn/tiy/t.asp?f=xmle_display_table_1)


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
.a {
border: 1px solid red;
}
</style>
<script type="text/javascript">
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "test.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
var html = "<table border=''1'' class=\"a\" style=\"width:100px;height:20px\">";
var x = xmlDoc.getElementsByTagName("CD");
for (i = 0; i < x.length; i++) {
html = html + "</td><td>";
html = html + x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
html = html + "</td><td>";
html = html + x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue;
html = html + "</td><td>";
html = html + x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue;
html = html + "</td></tr>";
}
html = html + "</table>";
document.write(html)
</script>
</head>
<body>
</body>
</html>
How to convert XML String into XML document
Sometimes,it is neccessary to convert string into document. For example,convert XML String into XML document.Actually,just use jquery as following:var xml = "<object><name>name</name><sex>boy</sex></object>"; $.parseXML(xml);//Generate document $($.parseXML(xml));//Generate document object
How to convert XML to Android Binary XML
figured this out using the Android packaging tool (aapt.exe)
aapt.exe package -f -m -J src -M AndroidManifest.xml -S res -A assets -0 "" -I android.jar -F MyApp.apk
This takes a plain xml manifest and packages it into binary XML and inserts it into the apk.
Unfortunately it requires that the resources and assets be present (if you refer to them within the manifest file itself). I also have to add any other data back into the apk file. Not ideal but it works at least
http://stackoverflow.com/questions/11367314/how-to-convert-xml-to-android-binary-xml
或使用axml开源项目:https://code.google.com/p/axml/
import pxb.android.axml.*; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class AXmlConverter { public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println("AXmlConverter INxml OUTxml"); return; } new AXmlConverter().a(new File(args[0]),new File(args[1])); } void a(File a,File b) throws Exception { InputStream is = new FileInputStream(a); byte[] xml = new byte[is.available()]; is.read(xml); is.close(); AxmlReader rd = new AxmlReader(xml); AxmlWriter wr = new AxmlWriter(); rd.accept(new AxmlVisitor(wr) { public AxmlVisitor.NodeVisitor first(String ns,String name) //manifest { return new AxmlVisitor.NodeVisitor(super.first(ns,name)) { public AxmlVisitor.NodeVisitor child(String ns,String name) //manifest's child nodes { if (name.equalsIgnoreCase("application")) { //we got application node return new NodeVisitor(super.child(ns,name)) { // @Override // public void attr(String ns,String name,int resourceId,int type,Object obj) { // if ("http://schemas.android.com/apk/res/android".equals(ns) // && name.equals("name")) { // super.attr(ns,name,resourceId,type,"com.secapk.wrapper.MyApplication"); // } else { // super.attr(ns,obj); // } // } public void end() { super.attr("http://schemas.android.com/apk/res/android","name",16842755,TYPE_STRING,"com.secapk.wrapper.MyApplication"); super.end(); } }; } return super.child(ns,name); } }; } }); byte[] modified = wr.toByteArray(); FileOutputStream fos = new FileOutputStream(b); fos.write(modified); fos.close(); } }
今天的关于Towxml的分享已经结束,谢谢您的关注,如果想了解更多关于10wx.showToast消息提示框 wx.showModal模态对话框、C# xml 读xml、写xml、Xpath、Xml to Linq、xml添加节点 xml修改节点、How to convert XML String into XML document、How to convert XML to Android Binary XML的相关知识,请在本站进行查询。
本文标签: