Questions tagged [xpathdocument]

.NET class that provides a fast, read-only, in-memory representation of an XML document by using the XPath data model

.NET class that provides a fast, read-only, in-memory representation of an XML document by using the XPath data model [MSDN]

31 questions
38
votes
1 answer

Tell StructureMap to use a specific constructor

I have two services that require an XPathDocument. I want to be able to define named instances of XPathDocumnet to use in the configuration of the two services. I also want to be able to tell StuctureMap which constructor of XPathDocument to use.…
awilinsk
  • 2,054
  • 6
  • 31
  • 50
2
votes
1 answer

Get only the first value from XPathNavigator?

var xml= @" The Gorgias3 Plato3
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
2
votes
1 answer

Get the sum of the same attribute from differently named xml nodes

I have an xml file as such Here's my code: XPathDocument xPathDocument = new XPathDocument(analysisFileToProcess); XPathNavigator Navigator =…
G. Abitbol
  • 189
  • 1
  • 1
  • 8
1
vote
1 answer

XPathDocument Threading Question

I have a web application where I am trying to cache an XPathDocument. The XPathDocument is created as follows. XPathDocument xdoc = new XPathDocument(new StringReader(ruleXml)); Then I want to just cache this xdoc and retrieve it for each…
Inquisitive
1
vote
1 answer

Import XML to Dataset or read XML using XPath?

I'd like to know what is the best practice. I'm exporting some data (tables) from my database to XML files so I can read my data from them. To export, I'm using DataTable.WriteXml (c#) Now to read, what is best? to import them into a dataset and use…
Androiderson
  • 16,865
  • 6
  • 62
  • 72
1
vote
3 answers

How do I use XPath to get the value of an attribute in c#?

I'd like to pass in an xpath query and return the value of what I find. I'm looking for the value of an attribute specifically. _query = "//@RequestType"; I can get the node back, but I'm not sure how to get the string value out of it. I want to…
ScArcher2
  • 85,501
  • 44
  • 121
  • 160
1
vote
1 answer

How do I modify node value while iterating with XPathNodeIterator?

I'm navigating XML document with XPathNodeIterator, and I want to change some nodes' values. I can't figure out how :( Here's the code I'm using: XPathDocument docNav = new XPathDocument(path); XPathNavigator nav =…
flamey
  • 2,311
  • 4
  • 33
  • 40
1
vote
0 answers

HP Fortify External Entity Injection Web API XPathDocument

HP Fortify has shown that some boiler plate code for .NET Web API 2 could be susceptible to External entity injection with xml. the code in question looks like this if (documentPath == null) { throw new…
Mateo
  • 187
  • 1
  • 4
  • 15
1
vote
1 answer

Can DocumentNode.SelectSingleNode skip selection of anchor tag events?

Given the following... HtmlNode myDiv = doc.DocumentNode.SelectSingleNode("//div[@id='someid']"); ...where the resulting myDiv.InnerHtml contains: ...other content I want to consume...
Clay
  • 1,273
  • 2
  • 16
  • 23
1
vote
1 answer

Reading XML using XPathDocument using NetworkStream

This hangs application: XPathDocument xPathDocument = new XPathDocument(networkStream); I think this is due to XPathDocument is still waiting for data, but how to prevent it?
Milek7
  • 157
  • 1
  • 10
1
vote
3 answers

Why do I get web exception when creating an XPathDocument?

Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?
Goran
  • 6,798
  • 9
  • 41
  • 57
1
vote
2 answers

C# XslCompiledTransform using XmlDocument or XPathDocument when editing is required?

I'm going on a couple assumptions here: XPathDocument is not editable. XmlDocument is editable. XPathDocument is more efficient for XslCompiledTransform. That being the case (and please correct me if I am wrong), would it be better (more…
aepheus
  • 7,827
  • 7
  • 36
  • 51
1
vote
3 answers

XslCompiledTransform output as XPathDocument

I am trying to use a XslCompiledTransform, and use the output as a XPathDocument. Any Ideas?
Irfy
  • 2,469
  • 4
  • 25
  • 31
1
vote
1 answer

XPathDocument behavior with DOCTYPE declaration

I use XPathDocument to parse an XML file, but if there's a doctype declaration, when I initializes a new instance of the XPathDocument class passing the path of the file, that contains the XML data, to its constructor, my application tries to…
gliderkite
  • 8,828
  • 6
  • 44
  • 80
0
votes
3 answers

XPath query that respect node positon and attribute value

Is there a way to build a XPath query that finds a node at a certain position AND with a certain attribute value? Consider the following sample xml:
bitbonk
  • 48,890
  • 37
  • 186
  • 278
1
2 3