我有一个问题,我一直试图解决几乎一个星期,但似乎不幸的是,我不能自己管理它.也许有人可以帮助我.
我有这种类型的源XML:
<data>
<para1>24499</para1>
<para2>32080148</para2>
<para4>20e500cc6008d0f8ab1fd108b220ca261f85edd9</para4>
<para6></para6>
<timetype>4</timetype>
<fkcontent>964342</fkcontent>
<season>0</season>
<fmstoken><![CDATA[7bca3c544ad64e526806fb5a6b845148]]></fmstoken>
<fmstoken_user>32010484</fmstoken_user>
<fmstoken_time>1283165972</fmstoken_time>
<fmstoken_renew><![CDATA[http://www.sky.com/logic/fmstoken.php?method=refresh]]></fmstoken_renew>
<adserverXML><![CDATA[http://www.sky.de/dummy.xml]]></adserverXML>
<playlist>
<videoinfo quality="0" name="DSL 1000">
<id>24499</id>
<noad>1</noad>
<productplacement>0</productplacement>
<filename>http://www.sky.com/video/1/V_53511_BB00_E81016_46324_16x9-lq-512x288-vp6-c0_bbb491b3ce64ef667340a21e2bfb3594.f4v</filename>
<title><![CDATA[Who will be the winner?]]></title>
</videoinfo>
<videoinfo quality="1" name="DSL 2000">
<id>24499</id>
<noad>1</noad>
<productplacement>0</productplacement>
<filename>http://www.sky.de/video/1/V_53513_BB00_E81016_46324_16x9-hq-512x288-vp6-c0_fa948bc5429cf28455779666cc59cf5e.f4v</filename>
<title><![CDATA[Who will be the winner?]]></title>
</videoinfo>
</playlist>
</data>
Run Code Online (Sandbox Code Playgroud)
这里是代码的一部分,让我从上面的xml页面获取所需的标记内容:
private static string getTagContent(string source, string tag)
{
string fullTagBegin = "<" + tag + ">";
string fullTagEnd = "</" + tag + ">";
int indexBegin = source.IndexOf(fullTagBegin) + fullTagBegin.Length;
int indexEnd = …Run Code Online (Sandbox Code Playgroud) 我有一些XML:
<metadata>
<dataIdInfo>
<idCitation>
<resRefDate>
<refDate>1996</refDate>
<refDateTyp>
<DateTypCd value="007" />
</refDateTyp>
</resRefDate>
<resRefDate>
<refDate>1998</refDate>
<refDateTypCd>
<DateTypCd value="003" />
</refDateTypCd>
</resRefDate>
</idCitation>
</dataIdInfo>
</metadata>
Run Code Online (Sandbox Code Playgroud)
我试图从关键007获得1996年的价值到目前为止我已经得到了这个
XmlDocument doc = new xmlDocument();
doc.LoadXml(myXmlString);
XmlNode node = doc.SelectSingleNode("metadata/dataIdInfo/idCitation/resRefDate/refDate[refDateType/DateTypCd[@value=\"007\"]");
Run Code Online (Sandbox Code Playgroud)
但我一直收到地址有无效令牌的错误.我一直在审查msdn上的XPath示例文档,但显然我在方括号部分出错了 - 求助!
谢谢Rob
我想使用saxon进行xpath查询,但我不知道加载多个xml文件.
我正在尝试使用saxon和Windows命令行
我在saxon手册中读到了我可以使用命令:
Query.exe -s:myDataFile.xml -q:myQueryFile -o:myOutputFile
但我不知道如何加载多个xml文件而不只是一个
编辑:我有很多的XML文件myDataFile1.xml,myDataFile2.xml,myDataFile3.xml ......我想运行查询到阿拉这些文件所以我要加载所有的所有文件,然后对它们进行查询(我不想查询每个文件,然后连接结果)
我正在获取一个HTML页面并尝试获取它的一些内容以在表格视图中显示它.在文档之后我尝试了NSXMLDocument和NSXmlParser,但是无法让他们中的任何一个给我正确的数据:-(
我想要废弃的页面是http://www.instapaper.com/u
我正在使用的代码是
NSXMLDocument * doc = [[NSXMLDocument alloc]
initWithXMLString: data
options: NSXMLDocumentTidyHTML
error: &error];
NSArray* rows = [doc nodesForXPath:@"//div[class='tableViewCell']" error:&error];
Run Code Online (Sandbox Code Playgroud)
用class = tableViewCell获取DIV.
如果我只搜索// div我会收到很多,但按类过滤似乎不起作用:-(
知道我做错了什么吗?
谢谢你的帮助,米格尔
得到这个xml:
<?xml version="1.0" encoding="UTF-8"?>
<video xmlns="UploadXSD">
<title>
A vid with Pete
</title>
<description>
Petes vid
</description>
<contributor>
Pete
</contributor>
<subject>
Cat 2
</subject>
</video>
Run Code Online (Sandbox Code Playgroud)
而这个xpath:
videoToAdd.Title = doc.SelectSingleNode(@"/video/title").InnerXml;
Run Code Online (Sandbox Code Playgroud)
我得到一个'对象引用未设置为对象的实例'.任何想法为什么这是一个有效的xpath我可以看到它曾经工作...
<attributes>
<attribute name="Mail Zone" property="alerts.p45" type="">
<value>mailzone</value>
</attribute>
<attribute name="Employee Name" property="acm_alert_custom_attributes.cs11" type="">
<value>employeename</value>
</attribute>
<attribute name="Manager Name" property="alerts.p23" type="">
<value><managername></value>
</attribute>
Run Code Online (Sandbox Code Playgroud)
如何<value>使用XPath基于上述XML的属性"name" 选择节点?
我的xml元素内容有特殊字符,如<,>,[,].我想找到元素macthing内容<![CDATA[someText]]>,并用一些新的值替换它<![CDATA[newValue]]>.
<property name="sourcePath">
<string><![CDATA[someText]]></string>
</property>`
Run Code Online (Sandbox Code Playgroud)
我试图使用下面的xsl模板来做到这一点.但它没有用.
<xsl:template match="property[string='<![CDATA[someText]]>']">
<xsl:element name="string">
<xsl:text disable-output-escaping="yes"><![CDATA[newValue]]></xsl:text>
</xsl:element>
Run Code Online (Sandbox Code Playgroud)
请帮忙.
这是XML.现在我想选择具有/ Home/Coverages/Coverage/Identifier/CoverageName ='WorkersCompensation'作为值的所有/ Home/Identifier/HomeNumber值.我在这个论坛上尝试过类似问题的答案,但似乎没有用.我需要帮助构建XPATH表达式.
<Home>
<Identifier>
<HomeNumber>1</HomeNumber>
</Identifier>
<Coverages>
<Coverage busStatus="Active">
<Identifier>
<CoverageName>PersonalLiability</CoverageName>
</Identifier>
</Coverage>
<Coverage>
<Identifier>
<CoverageName>WorkersCompensation</CoverageName>
</Identifier>
<Detail>
<Name>NumberOfInServants</Name>
<Value>
<Integer>1</Integer>
</Value>
</Detail>
</Coverage>
<covergaes>
</Home>
<Home>
.
.
.
</Home>
Run Code Online (Sandbox Code Playgroud) 首先我确实看到了这一点但它似乎没有帮助 .NET中的XPath SelectNodes
我正在尝试阅读SSRS报告定义.
ReportingService report = new ReportingService();
report.Credentials = System.Net.CredentialCache.DefaultCredentials;
string x = new System.Text.UTF8Encoding().GetString(
report.GetReportDefinition(ReportName));
//Remove a Character at the beginning of the document -- Char 65279
x = x.Replace(x.Substring(0, 1), "");
XmlDocument xml = new XmlDocument();
XmlNamespaceManager ns = new XmlNamespaceManager(xml.NameTable);
// This appears to be a reserved default?
//ns.AddNamespace("xmlns","http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition");
ns.AddNamespace("xmlns:rd","http://schemas.microsoft.com/SQLServer/reporting/reportdesigner");
xml.LoadXml(x);
Run Code Online (Sandbox Code Playgroud)
现在我正在寻找应该在的Query节点
Report
...
DataSets
DataSet
Query
Run Code Online (Sandbox Code Playgroud)
现在,如果我看一些变量
xml.Name = "#document"
xml.DocumentElement.Name = "Report"
xml.DocumentElement.ChildNodes[12].Name = "DataSets"
xml.DocumentElement.ChildNodes[12].ChildNodes[0].Name = "DataSet"
xml.DocumentElement.ChildNodes[12].ChildNodes[0].ChildNodes[1].Name = "Query"
Run Code Online (Sandbox Code Playgroud)
但问题是尝试了一些我无法访问此DataSet节点或任何子节点的事情.例
xml.DocumentElement.SelectNodes(".//DataSets",ns); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用bash实用程序解析此xml输入xpath:
<?xml version="1.0" encoding="UTF-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<entry>
<title>Title 1</title>
<author>Author 1</author>
</entry>
<entry>
<title>Title 2</title>
<author>Author 2</author>
</entry>
</feed>
Run Code Online (Sandbox Code Playgroud)
我需要这种格式的输出:
1. Title: Title 1
Author: Author 1
2. Title: Title 2
Author: Author 2
Run Code Online (Sandbox Code Playgroud)
我试图以一种简单的方式(仅使用一个xpath命令,或者最多3-4个命令)来解决这个问题,但我所有的努力都是徒劳的.有人可以帮我解决这个问题吗?