XmlDocument.SelectNodes() [英] XmlDocument.SelectNodes()
问题描述
嗨
我正在使用SelectNodes方法来查找是否存在后跟字符串的节点,如果是这样我将选择该节点。
我将选择该节点。
创建文档我这样的方式:
$ b $(DOC)b =新的XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration( " 1.0"," UTF-8英寸;,空));
docHandle = doc.CreateElement(QUOT;基地");
doc.AppendChild(docHandle);
之后:
nodes = doc.SelectNodes(path);
IMY的XmlDocument表示目录结构,并且在我添加元素i
查看如果每个目录(dir1\dir2\ ... DIRN)是否存在。
不幸的是''nodes = doc.SelectNodes(path)''在路径中引发了一个异常''无效
令牌'。
如需任何帮助 - 谢谢
-
Pozdrawiam
Piotr Kolodziej
http://piotrkolodziej.waikru.info
你好PiotrKolodziej,
Path查询是否在XML中找到节点?
可以在这里测试查询 http://www.activsoftware.com/xml/xpath/ 首先
检查你是否正在请求正确的节点?
P>嗨
P>我正在使用SelectNodes方法来查找节点后跟字符串
P>存在,并且
P>如果是这样我将选择该节点。
P>以这样的方式创建doc:
P> doc = new XmlDocument();
P> doc.AppendChild(doc.CreateXmlDeclaration(" 1.0"," UTF-8",null));
P> docHandle = doc.CreateElement(" Base");
P> doc.AppendChild(docHandle);
P>之后:
P> nodes = doc.SelectNodes(path);
P> IMy xmldocument表示目录结构,在我添加之前
P>我检查每个目录(dir1 \dir2 \ ... dirn)是否存在。
P>
P>不幸的是''nodes = doc.SelectNodes(path)''引发异常
P> ''路径中的令牌无效''。
---
WBR,
Michael Nemtsev ::博客: http://spaces.msn.com/laflour
有时一个人仍忠于某一事业,只因为它的反对者不会因为b $ b不再是平淡无奇的。 (c)Friedrich Nietzsche
>这条小路查询查找节点在XML?u能在这里测试查询<一个相对=nofollow的 href =http://www.activsoftware.com/xml/xpath/ target =_ blank> http://www.activsoftware.com/xml/xpath/ 首先要检查它是否正在请求正确的节点?
>
该节点并不总是存在于XMLdoc中。事实上,我正在以这样的方式使用它:
方式:
如果节点存在,请选择节点。
重要的是我想要找到从父节点开始的节点。
PiotrKolodziej< pi ************* @ gmail.com>写道:我使用SelectNodes方法查找是否存在后跟字符串的节点,如果是,我将选择该节点。
< snip>
不幸''nodes = doc.SelectNodes(path)''在路径中引发异常''无效
令牌''。
嗯,听起来这是你正在使用的路径的问题 -
很遗憾你没有发帖。
你能发一个简短但完整的节目来演示
的问题吗?
请参阅 http://www.pobox.com/~skeet/csharp /complete.html 了解详情
我的意思是什么。
-
Jon Skeet - < sk *** @ pobox.com>
http:// www。 pobox.com/~skeet 博客: http://www.msmvps。 com / jon.skeet
如果回复小组,请不要给我发邮件
Hi
I''am using SelectNodes method to find if node followed by string exists, and
if so i going to select that node.
Create doc i such a way:
doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
docHandle = doc.CreateElement("Base");
doc.AppendChild(docHandle);
After that :
nodes = doc.SelectNodes(path);
IMy xmldocument represents directory structure, and before i add element i
check if each of directories ( dir1\dir2\...dirn ) exists.
Unfortunately ''nodes = doc.SelectNodes(path)'' raises an exception ''Invalid
token in path''.
For any help - thanks
--
Pozdrawiam
Piotr Kolodziej
http://piotrkolodziej.waikru.info解决方案Hello PiotrKolodziej,
Does the Path query finds the node in your XML?
Can u test the query here http://www.activsoftware.com/xml/xpath/ first to
check it u are requesting the right nodes?
P> Hi
P> I''am using SelectNodes method to find if node followed by string
P> exists, and
P> if so i going to select that node.
P> Create doc i such a way:
P> doc = new XmlDocument();
P> doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
P> docHandle = doc.CreateElement("Base");
P> doc.AppendChild(docHandle);
P> After that :
P> nodes = doc.SelectNodes(path);
P> IMy xmldocument represents directory structure, and before i add
P> element i check if each of directories ( dir1\dir2\...dirn ) exists.
P>
P> Unfortunately ''nodes = doc.SelectNodes(path)'' raises an exception
P> ''Invalid token in path''.
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
> Does the Path query finds the node in your XML?Can u test the query here http://www.activsoftware.com/xml/xpath/ first to
check it u are requesting the right nodes?
The node is not always present in XMLdoc. In fact i''am using it in such a
way:
IF the node exists, select the nodes.
Important is that i want to find the node starting from the parent node.
PiotrKolodziej <pi*************@gmail.com> wrote:I''am using SelectNodes method to find if node followed by string exists, and
if so i going to select that node.
<snip>
Unfortunately ''nodes = doc.SelectNodes(path)'' raises an exception ''Invalid
token in path''.
Well, that sounds like it''s a problem with the path you''re using -
which unfortunately you didn''t post.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
这篇关于XmlDocument.SelectNodes()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!