.net - XPath, XPathNodeIterator To Be Exact?

Feb 7, 2012

Basically I have an XML file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<data>
<sender sndid="FT">

[code].....

View 1 Replies


ADVERTISEMENT

XML XPath Not Working

Oct 17, 2011

I have the following 2 lines of code:[code]I'm looking to get the value for first instance of lastWriteTime which should be 2011-10-13T10: 48: 48. 3833771-04:00 but the code just pops up an empty string. Sorry for the big post but here is the entire XML file for reference. Can anyone see why this isn't working, or give me an example of how to make it work some other way? [code]

View 2 Replies

XElement And An XPath Expression ?

Feb 1, 2010

I have an XElement and an XPath expression that selects a node from it. It works fine in the original program that I wrote it in but doesnt work if I paste it to another program. I've checked the references and import statements.

I think the problem might be that the original program had the code within the class of a wpf window while it was moved to a abstract class where it doesnt work.[code...]

View 1 Replies

Asp.net - Why Is This XPath Expression Getting Too Much Data

Nov 3, 2011

I have a XPath expression that is supposed to return/get only one node out of the XML document. But it is getting more than the one. I don't understand why.

Code-behind:

Dim xmlNameTbl As XmlNameTable = rootDoc.NameTable
Dim xmlNS As XmlNamespaceManager = New XmlNamespaceManager(xmlNameTbl)
xmlNS.AddNamespace("asp", "http://test.com/asp")

[code]....

View 1 Replies

Reading A XML File - XPath?

Apr 24, 2009

There are multiple occurances of the PLUS_BORROWER data. For each occurence of PLUS_BORROWER, I want to save the CREDIT_SCORE and DAYTIME_PHONE_NBR when the Type= And SOCIAL_SECURITY_NBR are certain values. Then I want to execute a loop and extract the Credit_Score and Daytime_Phone_Nbrs.

<PLUS_BORROWER Type="Primary"> <SOCIAL_SECURITY_NBR>123459999</SOCIAL_SECURITY_NBR> <CREDIT_SCORE ModelName="Emperica">793</CREDIT_SCORE> <DAYTIME_PHONE_NBR>4077889999</DAYTIME_PHONE_NBR> <DAYTIME_PHONE_EXT>101</DAYTIME_PHONE_EXT></PLUS_BORROWER>

I have the following code that will pull off the first PLUS_BORROWER if the Type='Primary', but I am having trouble expanding it.

oExtraData.Load(myXMLFile) 'only select nod with type attribute equal primary Dim oNode As Xml.XmlNode = oExtraData.SelectSingleNode("//PLUS_BORROWER[@Type='Primary']") 'get credit score node Dim scoreNode As Xml.XmlNode = oNode.SelectSingleNode("CREDIT_SCORE") MsgBox("I have the Primary") MsgBox("Credit score is " & scoreNode.InnerText)

View 5 Replies

Reading An XML File XPath

Apr 24, 2009

There are multiple occurances of the PLUS_BORROWER data. For each occurence of PLUS_BORROWER, I want to save the CREDIT_SCORE and DAYTIME_PHONE_NBR when the Type= And SOCIAL_SECURITY_NBR are certain values.Then I want to execute a loop and extract the Credit_Score and Daytime_Phone_Nbrs.[code]

View 3 Replies

VS 2008 XPath Items In For Each?

Sep 13, 2009

I have successfully loaded my .xml file into a listview using the

vb.net
'// Create an instance of the XML
Dim XMLItem As New Xml.XmlDocument

[Code]....

This load the "name" of the city into the listview, but i also need to load the "code" into the next column in the listview

View 4 Replies

XPath - How To Get Value Of Specific DIV From HTML

Oct 28, 2011

I'm trying to get the value of a specific <div> from an html. This div has a class attribute of "itemPrice6", but problem is that this class appears few more times for other <div>s in which i'm not interested in. Best thing for me is if I am able to access the needed <div> using something like XPATH so I can target only those I need.

My Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim web As New HtmlAgilityPack.HtmlWeb
Dim doc As HtmlAgilityPack.HtmlDocument = web.Load("[URL]")
Dim prices As HtmlAgilityPack.HtmlNodeCollection =
[Code] .....

View 3 Replies

Xpath With Xml String And Not Xml File

May 18, 2009

I am using the httplistener to grab xml off a POST.. so I dont have a file.. I just take the xml string and put to string.. but I tried to use this code..

[Code]...

View 5 Replies

C# - Xpath Expression To Loop Through Xmldocument?

Feb 19, 2012

trying to parse this:

<?xml version="1.0" encoding="UTF-8"?>
<directoryresponse xmlns="https://www.sisow.nl/Sisow/REST" version="1.0.0">
<directory>[code]......

Here's my code:

XPath = "//directoryresponse/directory/issuer/issuerid"
Dim nodeList As XmlNodeList = XML.SelectNodes(XPath)

but nodelist.count=0...why?

View 3 Replies

Can't Access Sub-nodes With XPath Expression?

Aug 12, 2010

Trying to figure out XPath and I have successfully create an XPathExpression that lets me grab the events, but any nested sub groups seem to be unavailable to the query, I can get all the children on the Events group, but the LocationName field I can not access.[code]...

View 1 Replies

Error When Use XPath.XPathDocument() Function

Jan 11, 2011

I'm using this code in my ASP.NET/VB.NET project:

Dim sourceFile as String = "http://xml.weather.yahoo.com/forecastrss?p=94704"
Dim xPath As New XPath.XPathDocument(sourceFile)

and the second line gives the error: "Unable to connect to the remote server"

When I browse the url (sourceFile) in web browser, it opens the RSS feeds page finely. How can I remove this error?

View 1 Replies

Get XPath Of Highlighted Text From A Webpage?

Feb 17, 2011

We want to get XPath of highlighted text from a web page. How to do, pls guide us.

Currently we are using GeckoFX layout engine to display web page. Its a windows application using VB.Net

We have to get selected text/object full html tag ..

ex: If I an selecting a list item which is under a body and div tag the I have to get like this \bodydivulli

View 1 Replies

Selecting XML Nodes Using XPath Syntax

Nov 9, 2011

Given the xml below why does the first selectsinglenode call not work but the second one does? Are the single quotes specifying a string type or something?
Dim dbglvlnode As Xml.XmlNode = doc.SelectSingleNode(String.Format("Config/Scanner[DeviceID = '{0}']/DebugLevel", XMLstuff.DeviceID))
Dim dbglvlnode As Xml.XmlNode = doc.SelectSingleNode(String.Format("Config/Scanner[DeviceID = {0}]/DebugLevel", XMLstuff.DeviceID))
<?xml version="1.0" standalone="yes"?>
[Code] ......

View 1 Replies

Use XPath To Navigate - Traversing The Nodes

May 12, 2011

The xml document is like so: ... I would like to use XPath to Navigate but I am not sure where to get started. Can anyone point me to some examples of traversing the nodes? I have the first part figured out but not sure how to iterate through all l1,l2,l3,l1 nodes...

[Code]...

View 2 Replies

Xml - Can't Get XPath Query To Return The Right Nodeset?

Jun 2, 2011

I've got an xml file that looks like this:

<Records>
<Record>
<table>[code].....

What I need is to select all the ROW nodes, across all records, so I'm using something like this:

rowiterator = Me.XMLDocument.CreateNavigator.Evaluate("//table/Row")

which is working, but it returns a NodeIterator that only contains the first Row node in the first record!? As far as I can tell, that's the proper syntax for an xpath expression of "return all Row nodes with a parent table name anywhere in the document".

View 1 Replies

Xml - Selecting A Single Node Using XPath

Oct 10, 2011

I'm simply trying to parse a SOAP Response and pull out the ResponseCode and UnconfirmedReasonCode Elements out of the following XML:

[code]...

View 1 Replies

Xpath - LINQ To XML Sum Child Nodes In .NET?

Nov 1, 2011

I have the following XML from Amazon's Marketplace API. I need to sum all the values of Item/ItemPrice/Component[type='Principal']/Amount for all Items to compute an order total. Is this possible to do using LINQ to XML in VB.NET?

<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>

[code]....

View 1 Replies

Xpath Coding For Different Sections Of The Xml Code?

Apr 10, 2009

I have an XML file (attached) that I need some help/advice xpath coding for different sections of the xml code.Below is a snippet (example) of the xml

<properties>
<list id="hnls">
<!-- START OF GUI HINTS AND TIPS -->
<record>

<string id="text" value="Selecting the national flag icon on any screen will take you to the senior national team screen.[COMMENT: Hints and Tips, GUI, Beginner Level, Note: tells the user how to use a shortcut to browse to national squad screens]" />

[Code]...

View 14 Replies

Xpath Preceding-sibling (using HtmlAgilityPack And VB)?

Sep 12, 2010

Im using HtmlAgilityPack/HAP so that I can use Xpath with HTML documents.selecting the preceding-sibling of div class="address" in this url[url].....The sibling that I want is h3 class="listingTitleLine" Here is a screenshot:

View 1 Replies

Xpath Query On An XML Returns 0 Results

Nov 13, 2011

I've converted an html to XML and now i want to get all the child nodes nested
within a DIV element with a specific attribute (class="itemInfo").

Because the html that the XML is based on changes from time to time i want to use a more "safe" relative root,[code...]

Problem is that i always get 0 nodes ...I'm sure that something is wrong with my Xpath syntax, just don't know what it is. Here is my code'[code...]

View 7 Replies

XPath Select An Attribute Based On Value?

Mar 26, 2010

Using VB.Net,I have an XmlNode object, xNode.I need to select an attribute of this node if it has a particular value.

e.g. xNode.SelectSingleNode(".[@attr1='1']")

I would expect this statement to return the attribute "attr1", only if it has a value of "1". However, I get an error - Expression must evaluate to a node-set.When I tried this - xNode.SelectSingleNode("@attr1[@attr1='1']")It always returns Nothing, even if the attribute has a value of 1.

View 1 Replies

Using Xpath To Retrieve The Text Content Of An Element?

Feb 15, 2011

I have been at it for few weeks now and just learning XML and VB but seems like I hit a road block. I tried a few different attempts at doing this and I have no problem displaying the XML file on a webpage using the xpathnavigator class. But then i needed to format into an html table so i took another route and just added the xmldatasource with a formview. So here is my code for that

<oriondata station='GiftShop'>
<meas name="GiftShopTime">2011/02/08 16:39:01</meas>
<meas name="GiftShopItemNumber">6</meas>

[code].....

View 3 Replies

VS 2010 : Xpath Query On A XML Returns 0 Results?

Nov 13, 2011

I've converted an html to XML and now i want to get all the child nodes nested within a DIV element with a specific attribute (class="itemInfo").Because the html that the XML is based on changes from time to time i want to use a more "safe" relative root,
(something like : "//div[@class='itemInfo']").Problem is that i always get 0 nodes ...

Dim doc As New System.Xml.XmlDocument()
doc.Load("products.xml")
Dim root As System.Xml.XmlElement = doc.DocumentElement

[code]....

View 6 Replies

Xml - Duplicate Selection In Text() XPath Selector

Jan 7, 2010

I'm trying to select all nodes with text that contain a certain word (ex: Company) because the word needs to have a register mark.

Here is part of the XHTML (this <p> is inside a table cell).

<p>
<strong>
<a style="color:#0E5A8B; text-decoration:none" target="_blank" href="http://www.trekk.com">

[Code]....

My goal is to just select the 2nd one, the <span> tag and am not sure why <p> tag is also being selected. If it selects <p>, but why wouldn't it also select the <strong> or <a>, and why not the <table> or <td> that contain the <p>?

View 1 Replies

C# - Identify Duplicate Nodes In XPath 1.0 Using A XPathNavigator To Evaluate?

Jun 27, 2012

I am trying to identify duplicate serial numbers from the following xml using XPath 1.0 and then evaluating it in .Net using an XPathNavigator.

<?xml version="1.0" encoding="utf-16"?>
<Inventory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Items>

[code]....

I tried to do this by evaluating this

//Items/Item/SerialNumber

expression in a custom XSLT Context Function (implementing IXsltContextFunction like this MSDN example) in .Net but the Invoke function gets called one result at a time so I have no visibility of the other results to find duplicates.

1) Is there a way of doing this using a single XPath 1.0 expression?

2) Is there a way of passing in an array of elements into a single Invoke call of the custom XSLT Context Function class? I'm working in VB.Net but am happy with any C# examples anyone can share.

View 2 Replies

Insert Numerical Data Variable Into XPath Expression

Jun 22, 2010

this list has tried to mix numerical variable, such as 1, 2,3 within an xpath expression. [code] For some reason, item_ number_ first and item_number_last appear to have no value in the above code snippet, when they do have values they get printed as in the [code]Could anyone please give me some hints on what to modify here to make the numerical data be able to mix within my xpath?

View 2 Replies

VS 2008 Parse A Incredibly Small XML File With Xpath

Mar 17, 2012

I have spent the last 20 plus hours trying to parse a incredibly small XML file with Xpath. I understand that it is a ready only, extremely fast way to pull values out of an xml file. Here is the string I am working with. I have a 3rd party function that returns results, based on these xml results i would like to retrieve certain vaules.

[Code]...

View 14 Replies

Xml - Find The String Position (index) From A XPath Statement?

May 7, 2009

I'm looking for the actual index position in a given source string.I have the following string

"<a>
<b>zyx</b>
<b>wvu</b>

[code]....

I'm loading that string into a .NET XmlDocument object. Carriage Returns and Line Fees may be a factor here.

Dim xmlSearchText As New XmlDocument()
xmlSearchText.LoadXml(SearchTextBox.Text)
Dim selectedNode As XmlNode = xmlSearchText.SelectSingleNode(txtSearch.Text)

The following XPath Statement could be used to find the 3rd node:

a/b[.='tsr']

However, I need it to return a string index of 23 rather than the ordinal position of 3.

View 2 Replies

XPath When A Root Node And Element Have Different Name Space Attributes?

Jun 8, 2010

I got struck with a problem in VB.Net getting Xpath for an XML element as shown below:

<Parent xmlns:"http://www.sample.com">
<body>
<Child xmlns:"http://www.notsample.com">

[code]....

I need Xpath of the "element" in above XML using VB.Net NameSpace Manager For the "body" node i have done and its working but i couldnt do the same to "element":

dim bodynode as XMLNode=XML.SelectSingleNode(//ns:body,nsmngr)

where "nsmngr" is the namespacemanger created by me and "ns" is the name space of the "parent node" (which the "body" node inherits) added to the namespace manager as "ns"

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved