Java 当提供元素值时,如何在XML字符串中查找行号?

Java 当提供元素值时,如何在XML字符串中查找行号?,java,xml,Java,Xml,我想在传递节点值时从dynamix XML字符串中获取行nimber。例如,如果我以“RSS Tutorial”的形式给出输入,那么输出应该返回行号9。如何在java中实现这一点 下面给出了示例XML <?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0"> <channel> <title>W3Schools Home Page</title> <l

我想在传递节点值时从dynamix XML字符串中获取行nimber。例如,如果我以“RSS Tutorial”的形式给出输入,那么输出应该返回行号9。如何在java中实现这一点

下面给出了示例XML

    <?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
  <title>W3Schools Home Page</title>
  <link>http://www.w3schools.com</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3schools.com/rss</link>
    <description>New RSS tutorial on W3Schools</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>http://www.w3schools.com/xml</link>
    <description>New XML tutorial on W3Schools</description>
  </item>
</channel>

</rss>

W3学校主页
http://www.w3schools.com
免费网页建设教程
RSS教程
http://www.w3schools.com/rss
新的学校RSS教程
XML教程
http://www.w3schools.com/xml
关于W3C学校的新XML教程

这提供了一种使用SAX、使用链接的有效方法。

通常不鼓励只使用链接的答案。试着在你的答案中添加一个小的代码示例或对博客内容的简要描述。@Rudi我不想剽窃别人的文章,我想说这种方法基于定位器,我提供的不仅仅是一个链接式的答案。