问题标签 [xmlnode]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
validation - 如何在 C# 的 XmlReaderSettings.ValidationEventHandler 中获取无效的 XMLNode
我正在尝试使用回调验证事件为不成功的 XML 验证构建自定义错误消息。我注意到元素的发送者对象是 XMLReader,我从 ((XmlReader)sender).Name 和 ValidationEventargs.Exception.Message 中获取了元素或当前节点名称和异常消息。我试图通过获取当前节点的父节点来构建验证失败的当前节点的路径
下面给出的是代码片段
c# - 按 ID 检索 Xml 节点的最快方法是什么
检索 XML 节点的最快方法是什么?我有一个应用程序需要替换特定节点的功能,当文档很小但很快变大时,需要几秒钟才能完成替换。这就是方法,我只是做了一个蛮力比较,在那种情况下真的很糟糕。
c# - 删除外部 xml 节点而不删除内部 xml
这是我的xml:
如何在<application>
不删除节点的情况下删除<test>
节点?
c# - Create single node if select single node is null
I have a program that updates a config file. For example, the config file may contain:
To update this config file, I use the following:
Now, during the update I want to update phoneNumber and address. Address may or may not be in the config file.
If SelectSingleNode is null, I would like to create a node with the given path and set its value.
How can I create the node with value at the given path?
c# - 如何将新的子节点添加到现有的子节点
我需要让汽车成为轨道的子节点。我在网上看过,并尝试了几种不同的方法,但我无法让它正常工作。
这是我生成的 xml 文件。
然而,这是预期的格式。
这是我生成 XML 文件的方法。请注意,消息的第一行是在其他地方生成的,我无法更改。
作为参考,这是 AppendNewChild 方法
xml - XmlNode.SelectNode Weirdness (Not finding one of two very similar nodes)
I ran into a bug with a piece of software I manage that is used to create Bills of Materials based on user selections. It works with a large xml file that contains all of our part numbers as well as rules that we have written that are used to select those part numbers based on the selections that the engineers make.
I realized today that on one very specific part, around half of the selections work while the other half don't. Here are the specifics.
We build a string based on the parameters of the rule in question, those parameters having been set based on the user selection. This string is passed to the XmlNode.SelectNode method:
Here are two examples of the xpath string, one that finds a node and one that doesn't:
A)
B)
The first string, A, will not return any nodes, while the second string, B, will. Here is the segment of our xml database that contains those part numbers:
(I removed some insignificant data from those entries, to make them shorter and easier to read here. In both cases the data removed is near identical, with differences only being costs/weights, etc.)
As you can see, both entries, A and B, are in the data file. The weirdest part is that I've been able to replicate the error with all of our different bearing sizes, and the ones that it does find have a double digit numerator in the fractional part of the number, and the ones that it doesn't find have a single digit numerator. Now that of course has to be a coincidence since it is just a string and should not matter at all, but it has held true for every size we have.
That's all I've got, I've been going over this with one of our other developers (the one that actually wrote the bulk of this program) and we are both at a loss. If anyone has any thoughts, please share. Also, I tried to be as thorough as I could be here, but if there is any need for additional information, I would be happy to add it.
Thanks.
EDIT: I have figured it out, finally.
Ok, so this ended up being a very weird thing that in the end wasn't related to the XmlNode.SelectNode function.
The XML file in question is compiled using a custom tool we created here from a collection of .csv files. The csv files make the data easier to manipulate when we need to make changes or things of that nature.
The tool that we have that compiles it also encrypts the file, as I mentioned earlier. We also have a version that will compile it without encryption which is how I was viewing it earlier.
When viewed unencrypted, the problematic line had one space in '1 7/16'
when the CSV file was viewed in notepad, there was one space.
when the CSV file was viewed in excel, it showed it with two spaces so that the columns matched up (excel formatting, ugh).
When I finally stepped through the code, and looked at the actual xml data in memory that it was searching on, the '1 7/16' had two spaces, so of course it never made a match.
In the end, I had to change the column of the CSV file in excel that held the diameter data to text format from number format, save it, and recompile. If I opened the CSV file again, changed nothing, and saved it, it would once again put the second space back in there.
I got it fixed though, and the program is working.
Thank you everyone for your responses (especially about the xpathvisualizer tool, very handy). This has been an exercise in frustration that burnt up my whole day.
c# - XmlDocument.SelectSingleNode 省略前缀和命名空间
这个问题是已回答问题的后续: XmlDocument.SelectSingleNode and prefix + xmlNamespace issue
问题是将来接收到的 xml 的命名空间前缀可能会在没有警告的情况下更改,因此我们想知道是否有任何方法可以使用 SelectSingleNode 但省略元素的前缀。
(我们知道我们可以删除传入 xml 的所有前缀,但这需要更多步骤......尽管如果提供了代码,我们会认为这是一个有效的答案......)
xpath - 如何在 camel-context.xml 中使用 xpath 来检查特定节点是否存在
我正在尝试开发基于内容的路由骆驼应用程序。此应用程序将查看文件夹 src/data 以查看是否存在具有 node 的 SOAP 请求文件<e2d:getOrderDetaiRequest>
,然后将该文件复制到 target/message,否则该文件将复制到 target/other。
你知道如何使用 xpath(或任何其他工具)来检查这种情况(我更喜欢使用 camel-context.xml 文件)吗?
这是我的骆驼上下文
这是 2 个不同 SOAP 请求的示例
和
android - 如何获得 NodeList 的结果?
请我想在我的文本视图中显示节点的值,但我无法获取节点的值。我有一个名为 country 和节点标记为 name、alpha2 和 dialingcode 的原始 xml 文件。下面是我的代码
我收到这个错误
03-16 16:19:02.478: E/AndroidRuntime(369): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 03-16 16:19:02.478: E/AndroidRuntime(369): 在 android. app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 03-16 16:19:02.478: E/AndroidRuntime(369): 在 android.app.ActivityThread.access$2300(ActivityThread.java:125) 03-16 16:19 :02.478: E/AndroidRuntime(369): 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 03-16 16:19:02.478: E/AndroidRuntime(369): 在 android.os.Handler。 dispatchMessage(Handler.java:99) 03-16 16:19:02.478: E/AndroidRuntime(369): 在 android.os.Looper.loop(Looper.java:123) 03-16 16:19:02.478: E/ AndroidRuntime(369): 在 android.app.ActivityThread.main(ActivityThread.java:4627) 03-16 16:19:02.478: E/AndroidRuntime(369): 在 java.lang.reflect。Method.invokeNative(Native Method) 03-16 16:19:02.478: E/AndroidRuntime(369): at java.lang.reflect.Method.invoke(Method.java:521) 03-16 16:19:02.478: E /AndroidRuntime(369): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 03-16 16:19:02.478: E/AndroidRuntime(369): 在 com.android.internal。 os.ZygoteInit.main(ZygoteInit.java:626) 03-16 16:19:02.478: E/AndroidRuntime(369): at dalvik.system.NativeStart.main(Native Method) 03-16 16:19:02.478: E /AndroidRuntime(369): 引起: java.lang.NullPointerException 03-16 16:19:02.478: E/AndroidRuntime(369): at com.tester.NewTester.onCreate(NewTester.java:61) 03-16 16: 19:02.478: E/AndroidRuntime(369): 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 03-16 16:19:02.478: E/AndroidRuntime(369): 在 android.app。ActivityThread.performLaunchActivity(ActivityThread.java:2627) 03-16 16:19:02.478: E/AndroidRuntime(369): ... 11 更多