从XML获取数据并将其放入链接中? [英] Get data from XML and put it in a link?
问题描述
[重新发布 XML检查重复项,然后保存,如果重复发现告诉我这件事 - SA]
再次问好,
我想要实现的目的是阅读我的部分XML并将该节点放入网页链接。
IE
www.Helloworld.com/[APIKEY]/[VCODE].jpg
你可以看到我有一个ID,所以当我想做倍数。
我的XML看起来像这样。
[Re-posted XML checking for duplicates before saving, if duplicate found tell me about it — SA]
Hello again,
what im trying to achive is to read part of my XML and put that node into a weblink.
I.E
www.Helloworld.com/[APIKEY]/[VCODE].jpg
as you can see i've got an ID so when i want to do multiples.
My XML looks like this.
</L><?xml version="1.0" encoding="utf-8"?>
<L xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ID>1c890a19-deae-406b-9e3f-5aeb779d06d4</ID>
<APIKEY>123</APIKEY>
<VCODE>123</VCODE>
</L><?xml version="1.0" encoding="utf-8"?>
<L xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ID>d179e9de-ec45-4986-9081-48ebb7466e46</ID>
<APIKEY>1234</APIKEY>
<VCODE>1234</VCODE>
</L><?xml version="1.0" encoding="utf-8"?>
<L xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ID>a169216d-efba-4bc2-86a8-1ba8fee3e585</ID>
<APIKEY>12345</APIKEY>
<VCODE>12345</VCODE>
</L>
以下是我制作XML的方法。
Here is how i made my XML.
public class L
{
static void main(string[] args)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("data.XML");
XmlNodeList userNodes = xmldoc.SelectNodes("data.XML");
foreach (XmlNode userNode in userNodes) ;
}
private string id;
private string APIkey;
private string VCode;
public string ID
{
get { return id; }
set { id = Guid.NewGuid().ToString(); }
}
public string APIKEY
{
get { return APIkey; }
set { APIkey = value; }
}
public string VCODE
{
get { return VCode; }
set { VCode = value; }
}
public static void SaveData(object obj, string Filename)
{
XmlSerializer sr = new XmlSerializer(obj.GetType());
TextWriter writer = new StreamWriter(Filename, true);
sr.Serialize(writer, obj);
writer.Close();
}
我试图在这里使用链接+信息导入图片我的XML。
Im trying to import a picture here using the link + the info in my XML.
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "www.Helloworld.com /[line in XML] /[the other line].jpg";
}
提前致谢:)
Thanks in advance :)
推荐答案
你不能这样做,因为你的数据文件是 而不是XML文件 。尝试打开任何浏览器;它会告诉你原因。 XML应该有一个根元素。有一个正确的XML文件,首先,格式良好,它会工作。
或者,创建自己的专有标准,称之为SuperXML(特别是如果它将成为XML的超集)并创建自己的生成器,解析器,或者可能是序列化。这是很有可能。只避免名称XML,甚至更好的文件命名方案* .XML。
[结束编辑]
但等一下...人们已经向您解释了这个问题:在保存之前检查重复项的XML,如果发现重复告诉我 [ ^ ]。
为什么你会忽略这些评论?请记住,重新发布被视为滥用。这里的主要部分是:如果您不能使用已经获得的建议,谁愿意在重新发布的问题上浪费时间?现在有一点希望你会使用。
-SA
You cannot do it, because you data file is not an XML file. Try to open it any browser; it will tell you why. XML should have one root element. Have a correct XML file, first of all, well-formed, and it will work.
Alternatively, create your own proprietary standard, call it, say, "SuperXML" (especially if it is going to be a superset of XML) and create your own generator, parser, and perhaps serialization. It is quite possible. Only avoid the name "XML" and better even the file naming schema *.XML.
[END EDIT]
But wait a minute… People already explained you this problem: XML checking for duplicates before saving, if duplicate found tell me about it[^].
Why would you ignore those comments? And remember, re-posting is considered as abuse. Main part here is: if you cannot use advice which you already got, who would like to waste time on your re-posted questions? There is a little hope now that you will use the.
—SA
这篇关于从XML获取数据并将其放入链接中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!