I have an XML file that I'm loading into an XmlDocument and need to get a list of all the attributes on nodes with a specific name.     &lt;shirts&gt;         &lt;product ID="123" Name="tee" Serial="5678"/&gt;         &lt;product ID="456" Name="crew" Serial="4566"/&gt;      &lt;/shirts&gt;     &lt;pants&gt;          &lt;product ID="123" Name="jeans" Serial="1243" Color="blue"/&gt;          &lt;product ID="123" Name="dress" Serial="3455" Color="black"/&gt;          &lt;product ID="123" Name="shorts" Serial="6654" Color="grey"/&gt;     &lt;/pants&gt;   From this I need a list of all the "product" attributes.  Result looking like:  ID Name Serial Color   I don't need the values, just the attributes themselves.  I'm using C# and Winforms.  I know how to get the attribute values but not sure how it's done to get the attribute names themselves.  How do I do that?
27747
Is there a simple method of parsing XML files in C#? If so, what?
37839
I am attempting to export a list of all item IDs, and metadata from  minecraft. I am using the FTB Unleashed pack. What I want is to write to file:  351:1 Ink Sac 351:2 Rose Red ... 368:0 Ender Pearl 369:0 Blaze Rod ... 2174:0 Naga Stone   Or something that I can convert to that with some regex etc.  NEI, and Item Resolver both only export item IDs. However this is not useful to me because some mod, heavily use the metadata value, to store a different item in the same ID space. The Vanilla Dye is an example of this.  I am coming the the conclusion I may just have to make it myself.  I would like this for computercraft fun. I many computercraft things return only the item id / metadata eg the ME Bridge and . Other computer craft mods (AE Peripheral, OpenCCsensors) do handle item names. However I am unwilling to add mods to the server. If a there is a mod I can use in single player to export all the ID, metadata and names, then I can use a computercraft program to parse it, that can run on the server. (I already have one working for ID/Name)
1146
I'm trying to retrieve a specific image from a html document, using html agility pack and this xpath:  //div[@id='topslot']/a/img/@src   As far as I can see, it finds the src-attribute, but it returns the img-tag. Why is that?  I would expect the InnerHtml/InnerText or something to be set, but both are empty strings. OuterHtml is set to the complete img-tag.  Are there any documentation for Html Agility Pack?
12617
I'm trying to understand how namespaces work in XML. When I have an element like foo:bar, the attributes will often not have namespaces on them. But sometimes they will. Are the attribute in the namespace of the element, even when the default namespace has been declared? Looking over the xsd for xhtml it seems the attributes are part of the schema and should be in the namespace for xhtml, but they are never presented that way...
108760
I know you can call density or flame for example from the attribute node. I was wondering what else you can write in the name slot. And maybe a bit of explanation of the attribute node.    thanks in advance guys! :)
43180
I'm trying to make a component in my community be able to pull in the record Id.  I followed the information in this question:   And this documentation:   My config file looks like this:  &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"&gt;     &lt;apiVersion&gt;45.0&lt;/apiVersion&gt;     &lt;isExposed&gt;true&lt;/isExposed&gt;     &lt;masterLabel&gt;ContractorSearch&lt;/masterLabel&gt;     &lt;description&gt;Searches for contractors for a given set of criteria&lt;/description&gt;     &lt;targets&gt;         &lt;target&gt;lightning__RecordPage&lt;/target&gt;         &lt;target&gt;lightningCommunity__Page&lt;/target&gt;         &lt;target&gt;lightningCommunity__Default&lt;/target&gt;     &lt;/targets&gt;     &lt;targetConfigs&gt;         &lt;targetConfig targets="lightning__RecordPage"&gt;             &lt;objects&gt;                 &lt;object&gt;Requisition__c&lt;/object&gt;             &lt;/objects&gt;         &lt;/targetConfig&gt;         &lt;targetConfig targets="lightningCommunity__Default"&gt;             &lt;property name="recordId" default="{!recordId}" type="String"                  label="Record ID" description="Should not be changed from default value."/&gt;         &lt;/targetConfig&gt;     &lt;/targetConfigs&gt; &lt;/LightningComponentBundle&gt;   Any ideas?
26112
Given this class  class Foo {     // Want to find _bar with reflection     [SomeAttribute]     private string _bar;      public string BigBar     {         get { return this._bar; }     } }   I want to find the private item _bar that I will mark with a attribute.  Is that possible?    I have done this with properties where I have looked for an attribute, but never a private member field.  What are the binding flags that I need to set to get the private fields?
91708
I have a sharepoint list with managed metadata column and I have to find items matching values from columns. If I filter the list for a column, let's say COLUMN1  &lt;In&gt;         &lt;FieldRef LookupId='TRUE' ID='919cad04-5872-42a5-8c79-93e38e5e5b96' /&gt;         &lt;Values&gt;           &lt;Value Type='Integer'&gt;65&lt;/Value&gt;         &lt;/Values&gt;       &lt;/In&gt;   It returns the record RECORD1.  Now i filter the list for a second column, let's say COLUMNB,   &lt;In&gt;         &lt;FieldRef LookupId='TRUE' ID='5a6a5ee4-d125-4c99-9109-f943d8da7af0' /&gt;         &lt;Values&gt;           &lt;Value Type='Integer'&gt;68&lt;/Value&gt;         &lt;/Values&gt;       &lt;/In&gt;   It returns record RECORD2. The issue is that if I run the query  &lt;Or&gt;         &lt;In&gt;           &lt;FieldRef LookupId='TRUE' ID='5a6a5ee4-d125-4c99-9109-f943d8da7af0' /&gt;           &lt;Values&gt;             &lt;Value Type='Integer'&gt;68&lt;/Value&gt;           &lt;/Values&gt;         &lt;/In&gt;         &lt;In&gt;           &lt;FieldRef LookupId='TRUE' ID='919cad04-5872-42a5-8c79-93e38e5e5b96' /&gt;           &lt;Values&gt;             &lt;Value Type='Integer'&gt;65&lt;/Value&gt;           &lt;/Values&gt;         &lt;/In&gt;       &lt;/Or&gt;   No record is returned. I was expecting both record RECORD1 and RECORD2. BTW SharePoint version is 2010.  Any help is appreciated
73459
I have an XML file on my server. In that file, I have many tags in which there is a tag for example, "container" tag. I need to fetch the content of all the container tags content separately. Many thanks in advance.
91839
I am having trouble constructing a single XPath statement to return two different sets of attributes.    For example take the following XML document:  &lt;root&gt;  &lt;line name="one" alpha="a1" beta="b1"/&gt;  &lt;line name="two" alpha="a2" beta="b2"/&gt;  &lt;line name="three" alpha="a3" beta="b3"/&gt; &lt;/root&gt;   If I use the following XPath statement:  //@alpha   It yields the following attribute set:  alpha="a1" alpha="a2" alpha="a3"   What statement do I use to yield the following attribute set:  alpha="a1" alpha="a2" alpha="a3" beta="b1" beta="b2" beta="b3"
43302
I have a complete XML document in a string and would like a Document object. Google turns up all sorts of garbage. What is the simplest solution? (In Java 1.5)  Solution Thanks to , I have settled on this implementation. It has the right level of input flexibility and exception granularity for me. (It's good to know if the error came from malformed XML - SAXException - or just bad IO - IOException.)  public static org.w3c.dom.Document loadXMLFrom(String xml)     throws org.xml.sax.SAXException, java.io.IOException {     return loadXMLFrom(new java.io.ByteArrayInputStream(xml.getBytes())); }  public static org.w3c.dom.Document loadXMLFrom(java.io.InputStream is)      throws org.xml.sax.SAXException, java.io.IOException {     javax.xml.parsers.DocumentBuilderFactory factory =         javax.xml.parsers.DocumentBuilderFactory.newInstance();     factory.setNamespaceAware(true);     javax.xml.parsers.DocumentBuilder builder = null;     try {         builder = factory.newDocumentBuilder();     }     catch (javax.xml.parsers.ParserConfigurationException ex) {     }       org.w3c.dom.Document doc = builder.parse(is);     is.close();     return doc; }
105678
My code looks like this:  &lt;ul id="ulList"&gt;   &lt;li class="listClass" id="id1"&gt;&lt;a href="http://link1"&gt;Link 1&lt;/a&gt;&lt;/li&gt;   &lt;li class="listClass" id="id2"&gt;&lt;a href="http://link2"&gt;Link 2&lt;/a&gt;&lt;/li&gt;   &lt;li class="listClass" id="id3"&gt;&lt;a href="http://link3"&gt;Link 3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;   Now I like to get the following:  All links as an array  All ids of li as an array  Can someone help me please?
123254
I've got a simple class that inherits from Collection and adds a couple of properties. I need to serialize this class to XML, but the XMLSerializer ignores my additional properties.  I assume this is because of the special treatment that XMLSerializer gives ICollection and IEnumerable objects. What's the best way around this?  Here's some sample code:  using System.Collections.ObjectModel; using System.IO; using System.Xml.Serialization;  namespace SerialiseCollection {     class Program     {         static void Main(string[] args)         {             var c = new MyCollection();             c.Add("Hello");             c.Add("Goodbye");              var serializer = new XmlSerializer(typeof(MyCollection));             using (var writer = new StreamWriter("test.xml"))                 serializer.Serialize(writer, c);         }     }      [XmlRoot("MyCollection")]     public class MyCollection : Collection&lt;string&gt;     {         [XmlAttribute()]         public string MyAttribute { get; set; }          public MyCollection()         {             this.MyAttribute = "SerializeThis";         }     } }   This outputs the following XML (note MyAttribute is missing in the MyCollection element):  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;MyCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;     &lt;string&gt;Hello&lt;/string&gt;     &lt;string&gt;Goodbye&lt;/string&gt; &lt;/MyCollection&gt;   What I want is  &lt;MyCollection MyAttribute="SerializeThis"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;     &lt;string&gt;Hello&lt;/string&gt;     &lt;string&gt;Goodbye&lt;/string&gt; &lt;/MyCollection&gt;   Any ideas? The simpler the better. Thanks.
66832
Given the below XML snippet I need to get a list of name/value pairs for each child under DataElements. XPath or an XML parser cannot be used for reasons beyond my control so I am using regex.  &lt;?xml version="1.0"?&gt; &lt;StandardDataObject xmlns="myns"&gt;   &lt;DataElements&gt;     &lt;EmpStatus&gt;2.0&lt;/EmpStatus&gt;     &lt;Expenditure&gt;95465.00&lt;/Expenditure&gt;     &lt;StaffType&gt;11.A&lt;/StaffType&gt;     &lt;Industry&gt;13&lt;/Industry&gt;   &lt;/DataElements&gt;   &lt;InteractionElements&gt;     &lt;TargetCenter&gt;92f4-MPA&lt;/TargetCenter&gt;     &lt;Trace&gt;7.19879&lt;/Trace&gt;   &lt;/InteractionElements&gt; &lt;/StandardDataObject&gt;   The output I need is:      [{EmpStatus:2.0},  {Expenditure:95465.00}, {StaffType:11.A}, {Industry:13}]    The tag names under DataElements are dynamic and so cannot be expressed literally in the regex. The tag names TargetCenter and Trace are static and could be in the regex but if there is a way to avoid hardcoding that would be preferable.   "&lt;([A-Za-z0-9]+?)&gt;([A-Za-z0-9.]*?)&lt;/"   This is the regex I have constructed and it has the problem that it erroneously includes {Trace:719879} in the results.  Relying on new-lines within the XML or any other apparent formatting is not an option.  Below is an approximation of the Java code I am using:  private static final Pattern PATTERN_1 = Pattern.compile(..REGEX..); private List&lt;DataElement&gt; listDataElements(CharSequence cs) {     List&lt;DataElement&gt; list = new ArrayList&lt;DataElement&gt;();     Matcher matcher = PATTERN_1.matcher(cs);     while (matcher.find()) {         list.add(new DataElement(matcher.group(1), matcher.group(2)));     }     return list; }   How can I change my regex to only include data elements and ignore the rest?
105580
In my Sp2013, I tried this link  http://mysite/_api/SP.UserProfiles.PeopleManager/GetMyProperties   and it gets all properties including the custom managed ones from crawling. And one of them is called Office which comes in the xml from above link.   This is in the big xml thats returned              &lt;d:element m:type="SP.KeyValue"&gt;                 &lt;d:Key&gt;Office&lt;/d:Key&gt;                 &lt;d:Value&gt;12-R&lt;/d:Value&gt;                 &lt;d:ValueType&gt;Edm.String&lt;/d:ValueType&gt;             &lt;/d:element&gt;   But then if I try this  http://mysite/_api/SP.UserProfiles.PeopleManager/GetMyProperties/Office   it says Office is not found...  How can I get it to return that?  Thanks
14810
I've got an XML document with a default namespace. I'm using a XPathNavigator to select a set of nodes using Xpath as follows:     XmlElement myXML = ...;   XPathNavigator navigator = myXML.CreateNavigator(); XPathNodeIterator result = navigator.Select("/outerelement/innerelement");   I am not getting any results back: I'm assuming this is because I am not specifying the namespace. How can I include the namespace in my select?
35657
I am using ASP.NET webforms on the .NET 3.5 framework. How can I achieve a custom attribute in the HTML tag such as:  &lt;HTML lang="en"&gt;   I want to achieve this in the code behind on a common inherited base page. The attribute value would dynamically set based on a session value everytime a page is loaded.  Late addition: I want to achieve this without any ASP page changes to script tags if possible