I have been parsing xml content using the xmlreader and cannot use the xml document but so far it works getting all elementcontent except for the attribute contents. I need to parse the link below found in the following entry;[code]
I'm using HtmlAgilityPack to parse HTML. I want to check if an element has a specific attribute. I want to check whether an <a> tag has the href attribute.
Dim doc As HtmlDocument = New HtmlDocument() doc.Load(New StringReader(content)) Dim root As HtmlNode = doc.DocumentNode Dim anchorTags As New List(Of String) For Each link As HtmlNode In root.SelectNodes("//a") If link.HasAttributes("href") Then doSomething() 'this doesn't work because hasAttributes only checks whether an element has attributes or not Next
I get an error when I try to build my project.'SSLAccessFiltercannot' be used as an attribute because it does not inherit from 'System.Attribute'. [code]
I would like to be able to parse vb.net code files, so I can examine the collection of Subs, Functions (and their contents, including comments), private variables, etc. I can be open the actual source code files. So for example, if I have:
I'm creating a vb.net winforms application that will take in user given strings, parse them, and print out labels with variable information. The given string will be used in all the labels, but the variable part of the string will change with each label.
My question is: is it better to parse the strings one time, then store those values in arrays, or to parse the string each time a label is printed? Which will perform better? Which is better practice? What is the proper way to test something like this?
I have created a loop to display the results. In the snippet above, how do i grab the attributes name(name, length, slope, and level_of_height). I have used reader.name is giving me RUNWAY which is correct as the elements name. I tried getAttribute and it give me all of the values of the attributes, but not there name.
In my VB 6.0 code, I declare have the following line[code]...
However, in VB.NET, I get the error "expecting declaration". Isn't this a declaration statement? Is there a good reference for finding the differences between VB.NET and VB 6.0?
I am converting C# code to VB.Net and the C code has this above the function:[return: System.Xml.Serialization.XmlElementAttribute("Name", IsNullable=true)]
what im trying to do is, i have the following xml:
Postcode id="E20 2AP" from="test1" to="test2"/>
im tring to search for the postcode id and then get the from and to text from that id the code i have:
Public Shared Function GetFromDate(ByVal PostCode As String) As String Dim LoadToAddresses = From ex In doc.Descendants.Elements("Postcode") Select New With {.accountName = ex.Attribute("id").Value, .datefrom = ex.Attribute("from").Value}
A former co-worker wrote a class in C# that was to be used as an attribute. I'm having to convert his work to VB (yeah, it's pointless and way more work than necessary, but management thinks it's a good idea). Unfortunately I'm having an issue because one of the main properties of the class is an ArrayList which is set with a ParamArray in the constructor. The class looks like this (note I've tried to abstract out the problem, so this is a simplified version of the class only)
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.[Property])> _ Public Class LabelAttribute Inherits Attribute Public Sub New()
[CODE]........
In the first one, there is just the single label being added. No Problem. In the second one there are 2 different labels being added. Again, no problem. The third one, however, is a problem because it's assuming that the "Description", which is supposed to be the description is instead being interpreted as another label.
This wasn't a problem in C# because it could be set as follows:
[CODE].................
Of course this doesn't work in VB because optional parameters aren't referred to by name as they are in C#. As a stopgap I've changed the constructor to allow only a single label like this
CODE]..................
But that undermines some of what this class is meant to do. Does anyone know how, or even if I can get the same basic functionality to work in VB?
Think there must be a way to make the existing design work. Imagine this class was built into a library that I could not modify. Would I be forever forbidden from setting Description because of this design?
How can I shift the GET-implementation of a Class property to a / using a custom attribute? (I've added instantation vars (classname, propertyname) to the attribute, however I'd rather have these automatically fetched ofcourse.)
Public Class CustomClass <CustomAttributeClass(ClassName:="CustomClass", PropertyName = "SomeProperty")> _ Public Property SomeProperty() as String Get() as String
This is my Effect.xml file .I am using vb.net to access this xml file. Actually i want to access effect name when i enter particular effect id.So that i will get attribute value of effect name when i give effect id as input value How can i do using vb.net
I'm using VB 2008 and I'm trying to add a xmlns="mynamespace" attribute to an XDocument's root element.The XML document is created by a 3rd party, and I have loaded it into a VB XDocument object. As it comes, it has no namespaces. I have been working on a local copy and I added in a namespace in a text editor, so that I can use the XMLToSchema in VB to enable intellisense etc, as per the instructions in the Beth Massi vids at MSDN. Now the rest of the code works I want to open the live documents again. Without the namespace, my XML literals don't resolve.I've tried unsuccessfully to add in the XMLNS property to the root tag using a few methods, and the nearest I got was the following three code samples.
Dim myNS As XNamespace = "urn:nbf:namespacename" myXML.Element("nameofrootelement").Add(myNS)
^^^^ The namespace was added as the value of the root element, not as an attribute.
XML.Root.Add(New XAttribute("xmlns", "name"))
^^^^ Generated the error: Run-time exception thrown : System.Xml.XmlException - The prefix '' cannot be redefined from '' to 'name' within the same start element tag.
but
XML.Root.Add(New XAttribute("test", "name"))
^^^^ works correctly. Presumably it doesn't like me manually trying to set a reserved attribute? This namespacing seems way too over complex from some of the Googling I've done.I thought to .ToString it, then modify, then .Parse it also, but I wanted a better solution so that it would help me understand it a little better! I did try this though, and as you rightly point out, it affects all the descendants too, so thus it still breaks.
I will be working with multiple XML feeds all produced by different third parties, and I think for simplicity I will be leaving out the namespacing entirely!My own custom parsing function rewrites the third party feeds into one uniformed document, which then gets processed by another routine. I'll be able to add a ns to that intermediate piece of XML which will help when coding the secondary function.
I have a page, divided into 3 section. Left Menu, Middle and Right Menu. Left Menu data comes from control, Middle Menu data is sorted on a page and Right Menu links also depends upon page to page so they are set on a page itself as
Why does Visual studio give this message in the task list when I use "onmousedown" on an asp:button:Could not find attribute 'onmousedown'of element buttonSurely it does exist. After all, it works! The same thing happens for "onmouseup"
I am trying to set a larger calendar font (Calendarfont) for a Datetimepicker control, but vb.net (2010) doesn't seem to use/honor it. It remains the same (very small) regardless of the font/size I choose.
Have also tried changing it in program on the onload of my form but that doesn't change anything either.
I have a list( of clsCourseList) which is a class that contains a boolean value "Scheduled" I want to return a boolean value if ANY of the items in the list of clsCourseList contain a "Scheduled" value of False.I was playing around and have this (courseList is the list of clsCourseList
courseList.Exists(Item.Scheduled = False)
but I receive an error for the item keyword. I don't really understand the syntax its just something I found online, but it was in C#.
The purpose of this is to quickly check if all classes are scheduled, without looping through each one as there are hundreds and this takes place a few times in the program.
I have an app that reads the file attribute to determine if it is normal, readonly or archive. Nowhere can I find the numerical values that equate to normal, readonly or archive, however I have debugged & found that archive is 32. The files on the cd are 33, what type of attribute is this and where is a list of all numerical values that equate to a file attributes type?
I use TortoiseSVN for versioning of my large VB Project in Visual Studio 2008. Once in a while, when editing one of the many typed DataSets, VS feels like switching the position of the attributes msprop:Generator_ColumnVarNameInTableand msprop:Generator_ColumnPropNameInRow In like nine THOUSAND places of the .xsd file. Sometimes I use a custom sed-script to reverse it again but most of the time I just commit it without knowing if there was any real change.
Can I prevent Visual Studio from messing with those attributes? Can I enforce a specific ordering? Or do I need some workflow within TSVN to ignore or revert such changes?
I wrote a small VB.Net Console app that scans thru the lines, sorting the attributes. It works on text alone as one cannot use xml parsing abilities without a massive increase in execution time and code size.