xmlnode

XML - How to grab child nodes in single node and not whole document?

≯℡__Kan透↙ 提交于 2019-12-11 03:29:33
问题 Been looking around for an answer and cant find anything - Im quite new so maybe Im not hitting up the right key words? This is a sample of the XML I am working with <database> <book> <title>A</title> <author> <name>1</name> </author> </book> <book> <title>B</title> <author> <name>2</name> </author> <author> <name>3</name> </author> <author> <name>4</name> </author> <author> <name>5</name> </author> </book> </database> Im trying to use C# XMLDocument to grab for book A author 1 and then for

Add a XmlNode with the namespace of the parent node in .Net

拟墨画扇 提交于 2019-12-11 01:28:49
问题 I am using XmlDocument and XmlNode to manipulate a xml file. Say I want to add a valid node called "Language" to the root, I use such code: Dim languageNode As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Language", Nothing) languageNode.InnerText = "en-US" root.AppendChild(languageNode) where xmlDoc is a XmlDocument object and has already been loaded. However, in the xml file after the operation, it appeas like this: <Language xmlns="">en-US</Language> And this doesn't pass the

Convert SQL table to XML with 2 node for each row

∥☆過路亽.° 提交于 2019-12-10 23:12:29
问题 My MS SQL table has following data ID CONTENT FLAG TEXT ---------------------------------- 1 content1 T text1 2 content2 F text2 3 content3 T text2 and i want to select values from this table in below format without any root node. <ADDRESS ID="1" FLAG="T"> <FORM CONTENT="content1" TEXT="text1"/> </ADDRESS> <ADDRESS ID="2" FLAG="F"> <FORM CONTENT="content2" TEXT="text2"/> </ADDRESS> <ADDRESS ID="3" FLAG="T"> <FORM CONTENT="content3" TEXT="text3"/> </ADDRESS> 回答1: This is quite a while ago, but

Get value from node with same name

雨燕双飞 提交于 2019-12-10 21:39:05
问题 I'd like to retrieve information from an XML file, however the way it's formatted is pretty strange. Here it is... <?xml version="1.0"?> <Careers> <CareerList> <CareerName></CareerName> <CareerDescription></CareerDescription> </CareerList> <CareerList> <CareerName>Cook</CareerName> <CareerDescription>Cooks food for people</CareerDescription> </CareerList> </Careers> I'd like to get the 2nd value, which would be Cook and the description which is Cooks food for people, but instead I'm getting

string to xmlNode delphi (or how to add an xml fragment to TXMLDocument)

时间秒杀一切 提交于 2019-12-10 15:24:28
问题 I Have a few text strings that contain well formed XML. I would like to be able to (1) turn these strings into IXMLNodes then (2) append them to an existing XMLDocument . Preferably without declaring a new XMLDocument first. This doesn't seem possible? Is there any easy way to accomplish something equivalent though? My initial thought was to use the IXMLNode.XML (string) property and insert the new strings. No such luck as IXMLNode.XML is Read Only. Here is an example, if I had the following

setting parent node in javascript

不想你离开。 提交于 2019-12-10 11:48:54
问题 when Im cloning an object in javascript by doing object.cloneNode(true) the parentNode is null in the new copy. Im trying to set it but with no success. my code look like this: old_DataRoot = DataRoot.cloneNode(true); old_DataRoot.parentNode=DataRoot.parentNode.cloneNode(true); also tried: old_DataRoot = DataRoot.cloneNode(true); old_DataRoot.parentNode.appendChild(DataRoot.parentNode.cloneNode(true)); both options give me "old_DataRoot.parentNode is null or not an object" what am I doing

Dealing with empty XML nodes in R

五迷三道 提交于 2019-12-07 15:06:56
问题 I have the following XML file (I am missing the root node but the editor is not allowing me--please assume there is a root node here): <Indvls> <Indvl> <Info lastNm="HANSON" firstNm="LAURIE"/> <CrntEmps> <CrntEmp orgNm="ABC INCORPORATED" str1="FOURTY FOUR BRYANT PARK" city="NEW YORK" state="NY" cntry="UNITED STATES" postlCd="10036"> <BrnchOfLocs> <BrnchOfLoc str1="833 NE 55TH ST" city="BELLEVUE" state="WA" cntry="UNITED STATES" postlCd="98004"/> </BrnchOfLocs> </CrntEmp> </CrntEmps> </Indvl>

Remove empty nodes from a XML recursively

耗尽温柔 提交于 2019-12-07 11:17:50
问题 I want to delete the empty nodes from an XML element. This xml is generated from a vendor and i dont have control on xml generation. But since the XML has few empty nodes i need to delete those empty nodes recursively. This xml is got from OMElement and i get an Element from this object using [XMLUtils][1] Sample XML <A> <B> <C> <C1> <C11>something</C11> <C12>something</C12> </C1> </C> <D> <D1> <D11> <D111 operation="create"> <Node>something else</Node> </D11> </D11> </D1> <D2> <D21> </D21> <

Webservice method return XmlDocument, Reference sees a XmlNode

半城伤御伤魂 提交于 2019-12-07 10:10:50
问题 I've faced a problem I can't solve that's why I beg you to help me! I'm working with a WebService and I'm trying to return a XmlDocument from a WebService method called GetSystemDocument which looks like : [WebMethod(Description = "blabla")] public XmlDocument GetSystemDocument(string DocumentName) { return new XmlDocument(); } In the project where I reference this web service. Visual Studio tells me it cannot implicitily convert type 'System.Xml.XmlNode' to 'System.Xml.XmlDocument'. If I

Convert org.w3c.dom.Node into Document

谁都会走 提交于 2019-12-06 17:30:42
问题 I have a Node from one Document . I want to take that Node and turn it into the root node of a new Document . Only way I can think of is the following: Node node = someChildNodeFromDifferentDocument; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document newDocument = builder.newDocument(); newDocument.importNode(node); newDocument.appendChild(node); This works, but I feel it is