FAQ Database Discussion Community


C# cannot get values from list of objects

c#,xml,xmldocument
I have my main Program class that calls the StronyElementuStrukt procedure List<object> monthlyPages = new List<object>(); monthlyPages = StronyElementuStrukt(loginGuid, "8B35134E10A8432DB1A8C06A58427988"); Here is the procedure - a method that builds a list of xml nodes and returns it to the main Program class: public static List<object> StronyElementuStrukt(string LoginGUID, string LinkGUID) {...

Read only root-element from XML

c#,xml,linq-to-xml,xmldocument
I have a very large xml-file (let's say it has about 300000 elements). In my part of the application I only have to know if the name of the root-element is ApplicationLog and if there is an attribute called LogId in the root-element. To read the XML I use: XDocument...

how to import node in XML

c#,linq-to-xml,xmldocument
Parent XML <order> <class/> <account> <saving/> </account> </order> I want to import node to parent xml Node: <data> <address/> </data> After importing, final xml as <order> <class/> <account> <saving/> </account> <data> <address/> </data> </order> Please help me here I tried as below: XmlDocument doc = new XmlDocument(); doc.LoadXml(childXML.InnerXml); mlNode newNodeDataset...

Find and number consecutive XML elements

c#,xml,xmldocument
I have an XML document that looks kinda like this: <root> Maybe some text <thing>thing can have text</thing> <thing>it can even be on multiple lines </thing> <thing>a third thing</thing> This text resets the numbering <thing>this thing is not part of the above list and should have number 1</thing> <some-element-not-thing>Also resets...

Read XML by xpath containing namespace prefix

c#,xml,xpath,xmldocument
im trying to read from this http://api.hostip.info/?ip=12.215.42.19 XmlDocument xml = new XmlDocument(); xml.Load("http://api.hostip.info/?ip=79.177.176.8"); XmlNodeList xnList = xml.SelectNodes("gml:featureMember/Hostip"); foreach (XmlNode xn in xnList) { string Name = xn["countryName"].InnerText; MessageBox.Show(Name); } im getting a weird error Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function. never seen...

Adding line breaks and indents to XmlDocument

.net,line-breaks,xmldocument
What is the right way of adding line breaks and indents when building an XmlDocument to make its output (called by xmlDocoment->DocumentElement->OuterXml) look like this: <QualifyingProperties Target="#SignatureElem_0" xmlns="http://uri.etsi.org/01903/v1.3.2#"> <SignedProperties Id="SignedPropertiesElem_0"> This is the way I build my XmlDocument: XmlDocument^ xmlDoc = gcnew XmlDocument(); xmlDoc->PreserveWhitespace = true; XmlNode^ nQualifyingProperties = xmlDoc->CreateNode(XmlNodeType::Element,...

XmlDocument saving the file incompletely

c#,xml,xamarin,monodroid,xmldocument
I have a simple code which modifies an existing XML file as follows: roomsfile = new File(Path.Combine(rootDir, "rooms.dat")); XmlDocument roomdata = new XmlDocument(); roomdata.Load(roomsfile.AbsolutePath); XmlElement root = roomdata.DocumentElement; XmlNode roomNode = roomdata.CreateElement("room"); XmlNode noNode = roomdata.CreateElement("no"); XmlNode nameNode = roomdata.CreateElement("name"); //roomNo and roomName are text fields noNode.InnerText = roomNo.Text; nameNode.InnerText...

Convert Xml document to C# Dictionary

c#,xml,dictionary,xmldocument,httpwebresponse
I make a request to a service and receive an xml response as shown below. However, I'm trying to store the response values in a Dictionary (or store the values returned in variables) and I can't seem to make it work. Any help would be greatly appreciated. xml response received:...

XPath Expression with functions

c#,xml,xpath,xmldocument
I am trying to construct a XPath Expression to obtain the prices of all the albums, which were published at least 5 years ago. The XML document has the following structure: <catalogue> <album> <year>1990</year> <price>7.99</price> ... </album> </catalogue> I tried with the following, but obviously, it has a problem: string...

XMLDocument.Importnode fails

c#,xml,excel,xmldocument,xmlnode
i´m currently working on a Project where i have to create XMLNodes and insert them at specific places in the XML File. The XMLNode is a Row with around 90 Cells. <Row ss:AutoFitHeight=\"0\"> <Cell ss:StyleID=\"s77\"><Data ss:Type=\"String\">ABC</Data></Cell> <Cell><Data ss:Type=\"Number\">100</Data></Cell> <Cell ss:StyleID=\"s77\"><Data ss:Type=\"String\">ABC</Data></Cell> <Cell><Data ss:Type=\"String\"...

Builder C++: XMLDocument Replace Node

c++,xml,c++builder,xmldocument
I need to replace all nodes with others nodes. My current node: <str name="author">Brad Mc</str> I need to replace it with this node: <author>Brad Mc<author> I have this code to replace all nodes with others nodes: IXMLNode* xResultNode = XMLDocument1->DocumentElement->ChildNodes->FindNode("result"); IXMLNode* xDocNode; IXMLNode* xFieldNode; IXMLNode* xNewFieldNode; // <result> for (int...

XmlDocument XSD Validation does not find error

c#,xml,validation,xsd,xmldocument
I build my XmlDocument in code. Before returning it I want to validate it against an XSD defined in a file. xmlDocument.Schemas.Add(null, "MySchema.xsd"); xmlDocument.Validate((sender, e) => { if (e.Severity == XmlSeverityType.Error) { // Write error to log } }); There never occurs any error. Although I added an error to...

XmlDoc throws the process cannot access the file from tome to time?

c#,.net,xml,filestream,xmldocument
I have the following code for writing XML file based on datacontracts public static void LogDataContractToFile(string XMLStringToLog, string filePathAndName) { //String documentPath = string.Empty; String xmlObject = string.Empty; FileInfo fileinfo; XmlDocumentFragment xmlDocumentFragment; XmlTextWriter xmlWriter; XmlDocument xmlDocument = null; lock (LogDataContractToFileLock) { filePathAndName = filePathAndName.ToLower(); while (_workingWithFile.Contains(filePathAndName)) Thread.Sleep(1000); _workingWithFile.Add(filePathAndName.ToLower());...

Creating a document in Java

java,xml,kml,xmldocument
I am creating a KML document in Java. Inside of it i have to add many similar elements, resulting in the need to add a function, where I can pass needed arguments. The problem is that when I try to add a part of the document into the main document...

Reading XML using XmlDocument

c#,xml,ssis,xml-parsing,xmldocument
This is my feed. <feed xml:lang=""> <title>NEWS.com.au | Top Stories</title> <link rel="self" href="http://feeds.news.com.au/public/atom/1.0/news_top_stories_48_48.xml"/> <link rel="alternate" href="http://news.com.au"/> <id>http://news.com.au</id> <rights/> <entry> <title>F1’s glaring issues exposed</title> <link href="www.google.com"/> <author> <name>STEVE LARKIN</name> </author> <link rel="enclosure" type="image/jpeg"...

Search Xml NodeList By Xpath and Bind In nested GridView

c#,asp.net,xml,xpath,xmldocument
i just want to bind xml in to gridview which multiple child node like this.. <?xml version="1.0" encoding="utf-8" ?> <Products> <Product> <SKU>DL-DL4002</SKU> <Name>Leopard Print Strapless Corset Top with G-string</Name> <ImagePath4> http://da.com/images/product/large/DL-DL4002_4_.jpg </ImagePath4> <Variants> <Variant> <Size>S</Size> <Cost>25.28</Cost> <MSRP>57.45</MSRP> <Avialability>in stock</Avialability>...

Can't select descendant nodes despite not having namespaces declared on them

c#,xml,xml-namespaces,xmldocument
I'm trying to read some XML: <?xml version="1.0" encoding="UTF-8"?> <gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"> <gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender> <gesmes:name>European Central Bank</gesmes:name> </gesmes:Sender> <Cube> <Cube time='2015-02-23'> <Cube currency='USD' rate='1.1298'/> <Cube currency='JPY' rate='134.50'/> <Cube currency='BGN'...

Get value of single node yields “… value of Nothing”

xml,vb.net,xmldocument
I've got an XmlNode object rowNode, and when I call rowNode.OuterXml I get this result: <Row Nr="1"> <Område FormulaR1C1="" /> <Position FormulaR1C1="" /> <Lev FormulaR1C1="" /> <Option FormulaR1C1="" /> </Row> I'm trying to get the value of Område with the following code: rowNode.SelectSingleNode("/Row/Område").InnerText and I get Referenced object has a...

Convert contents of an XmlNodeList to a new XmlDocument without looping

c#,xml,xpath,xmldocument,xmlnodelist
I have Xml that I filter using XPath (a query similar to this): XmlNodeList allItems = xDoc.SelectNodes("//Person[not(PersonID = following::Person/PersonID)]"); This filters all duplicates from my original Persons Xml. I want to create a new XmlDocument instance from the XmlNodeList generated above. At the minute, the only way I can see...

Can't set settings on XmlTextReader?

c#,.net,xml,xmldocument,xmlreader
I need to set the MaxCharactersFromEntities on the XmlTextReader, this is my code so far : xmlDocument = new XmlDocument(); xmlTextReader = new XmlTextReader(fileInfo.FullName); xmlTextReader.Settings = new XmlReaderSettings(); xmlTextReader.Settings.MaxCharactersFromEntities = 0; var vr = new XmlValidatingReader(xmlTextReader); vr.ValidationType = ValidationType.None; vr.EntityHandling = EntityHandling.ExpandEntities; xmlDocument.Load(vr); The Settings property is read-only so it...

Trying to change a XML node with no success

c#,.net,xml,xmldocument
I'm trying to change a the value for the model atribute from the following .xml file. <MTConnectDevices xmlns="urn:mtconnect.org:MTConnectDevices:1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mtconnect.org:MTConnectDevices:1.1 http://www.mtconnect.org/schemas/MTConnectDevices_1.1.xsd"> <Header version="1.1" sender="Company MTConnect Instance" creationTime="2010-08-26T19:00:47-07:00" instanceId="2" bufferSize="131072" /> <Devices> <Device name="XX" iso841Class="1"...