孩子的孩子用XML(Child's child in XML)
我有一个简单的XML文件,由下面发布的脚本加载到页面上。 它从字符串转换为XML文件没有任何问题,但是使一切变得复杂的事实是,我无法接触到孩子的孩子。
我想知道为什么我的代码不起作用,我该怎么做才能得到标签名称。
function load_xml() { $.ajax({ type: "GET", url: "file.xml", dataType: "xml", success: function (xmlData) { var $first_child = $(xmlData).children()[0]; var first_name = $first_child.nodeName; // returns a proper name of a node var $second_child = $first_child.children()[0]; // doesn't work var $second_name = $second_child.nodeName; // returns nothing (don't know why) }, error: function () { alert("Could not retrieve XML file."); } }); }
i have a simple XML file which is loaded on page by a script posted below. It converts from a string to a XML file without any problems, but what complicates everything is the fact, that I can't get to a child's child.
I'd like to know why my code doesn't work and what should I do to get the tag name.
function load_xml() { $.ajax({ type: "GET", url: "file.xml", dataType: "xml", success: function (xmlData) { var $first_child = $(xmlData).children()[0]; var first_name = $first_child.nodeName; // returns a proper name of a node var $second_child = $first_child.children()[0]; // doesn't work var $second_name = $second_child.nodeName; // returns nothing (don't know why) }, error: function () { alert("Could not retrieve XML file."); } }); }
原文:https://stackoverflow.com/questions/25450237
最满意答案
希望本文将有助于您:
如何从UNIX格式的Visual C ++中保存文件
不幸的是,默认情况下,它似乎是以Unix格式保存文件的唯一方法。
个人我在保存文件对话框中使用高级保存选项。 但是要做到这一点,我从来没有需要使用MSVS中Unix格式的大量文件。
Hope this article will help you:
How To Save a File from Visual C++ in UNIX Format
Unfortunately it seems to be the only way to save files in Unix format by default.
Personally I use Advance Save option in Save File dialog. But to be hones I never have a need to work with large number of files in Unix format from MSVS.
相关问答
更多-
希望本文将有助于您: 如何从UNIX格式的Visual C ++中保存文件 不幸的是,默认情况下,它似乎是以Unix格式保存文件的唯一方法。 个人我在保存文件对话框中使用高级保存选项。 但是要做到这一点,我从来没有需要使用MSVS中Unix格式的大量文件。 Hope this article will help you: How To Save a File from Visual C++ in UNIX Format Unfortunately it seems to be the only way to ...
-
这里有更多的链接: http : //social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/290fb587-1447-466c-9149-a692fa5de34d他们似乎指向相同的文件。 直接下载链接: http : //go.microsoft.com/fwlink/?LinkId=51411&clcid=0x409 Here are more links: http://social.msdn.microsoft.com/Forums/e ...
-
这是使用.gitattributes文件完成的,该文件允许您通过模式匹配文件名,根据匹配分配预期的行为。 进一步阅读: 处理行结尾 ,显示了一个带有模式的示例 : # Declare files that will always have CRLF line endings on checkout. *.sln text eol=crlf gitattributes - 定义每个路径的属性 Ensure the repo has core.autocrlf set: git config ...
-
你也可以使用cccl和make for windows 。 cccl是Microsoft Visual C ++的cl.exe和link.exe的包装器。 它将Unix编译器参数转换为cl和link所理解的参数。 You can also use cccl with make for windows. cccl is a wrapper around Microsoft Visual C++'s cl.exe and link.exe. It converts Unix compiler parameter ...
-
通过规范化不一致的行结尾,Visual Studio意味着什么?(What does Visual Studio mean by normalize inconsistent line endings?)[2022-09-25]
这通常意味着您的行以逗号返回/换行对象以外的行结束。 当您从网页复制并粘贴到代码编辑器中时,通常会发生这种情况。 规范线条结尾只是确保所有行结束字符是一致的。 它阻止一行以\r\n结尾,另一行以\r或\n结尾; 第一个是Windows线端对,而其他的通常用于Mac或Linux文件。 由于您在Visual Studio中开发,因此您显然需要从下拉列表中选择“Windows”。 :-) What that usually means is that you have lines ending with some ... -
在Windows下,如何强制git使用LF而不是CR + LF?(How do I force git to use LF instead of CR+LF under windows?)[2023-05-23]
OP在他的问题上补充说: 使用msysgit签出的文件正在使用CR+LF ,我想伪造msysgit以使用LF 第一个简单的步骤仍然在.gitattributes文件中: *.txt -crlf ,以避免对具有正确eol的文件进行任何crlf转换。 查看跨平台git配置的最佳做法? 但是第二个更强大的步骤涉及到gitattribute过滤器驱动程序,并添加了一个涂抹步骤 每当你更新你的工作树,一个脚本就可以,只有你在.gitattributes指定的文件,强制LF eol和你要强制执行的任何其他格式化选项。 ... -
我采取了恩迪的步骤,但减少到只使用一个单一的存储库: 1. git config core.autocrlf true 2. delete all files in your working tree (except the .git folder for sure) 3. git checkout -f 4. git config core.autocrlf false 5. git commit -am "corrected all line endings from LF to CRLF" I mi ...
-
要使用Unix行结尾创建新文件,请设置Window> Preferences> General> Workspace> New text file line delimiter> Unix。 要将现有行结尾转换为Unix样式,请执行文件>将行分隔符转换为> Unix。 更新 :如果在执行File> Convert Line Delimiters to> Unix之前在项目视图中选择项目,则此转换也适用于整个项目。 至少在我的测试中,二进制文件不受此质量转换的影响。 To create new files w ...
-
看看这个问题 ,它有一个完整的清单。 Have a look at this question, it has a complete list.
-
哇噢! 我想我找到了答案。 本网站http://lostechies.com/keithdahlby/2011/04/06/windows-git-tip-hide-carriage-return-in-diff/建议做 git config [--global] core.whitespace cr-at-eol 这确实关闭了“git diff”。 当然,最好的解决方案是在.gitattributes文件中执行等效操作,以使其与repo保持一致,并且不依赖于用户的设置。 .gitattributes的确 ...