Search Results

Search found 3195 results on 128 pages for 'doc'.

Page 22/128 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • What's the most concise cross-browser way to access an <iframe> element's window and document?

    - by Bungle
    I'm trying to figure out the best way to access an <iframe> element's window and document properties from a parent page. The <iframe> may be created via JavaScript or accessed via a reference stored in an object property or a variable, so, if I understand correctly, that rules out the use of document.frames. I've seen this done a number of ways, but I'm unsure about the best approach. Given an <iframe> created in this way: var iframe = document.createElement('iframe'); document.getElementsByTagName('body')[0].appendChild(iframe); I'm currently using this to access the document, and it seems to work OK across the major browsers: var doc = iframe.contentWindow || iframe.contentDocument; if (doc.document) { doc = doc.document; } I've also see this approach: var iframe = document.getElementById('my_iframe'); iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument; iframe.document.open(); iframe.document.write('Hello World!'); iframe.document.close(); That confuses me, since it seems that if iframe.contentDocument.document is defined, you're going to end up trying to access iframe.contentDocument.document.document. There's also this: var frame_ref = document.getElementsByTagName('iframe')[0]; var iframe_doc = frame_ref.contentWindow ? frame_ref.contentWindow.document : frame_ref.contentDocument; In the end, I guess I'm confused as to which properties hold which properties, whether contentDocument is equivalent to document or whether there is such a property as contentDocument.document, etc. Can anyone point me to an accurate/timely reference on these properties, or give a quick briefing on how to efficiently access an <iframe>'s window and document properties in a cross-browser way (without the use of jQuery or other libraries)? Thanks for any help!

    Read the article

  • How do I load an XML document, add and remove nodes, then apply it to a ASP DataGrid control?

    - by JFOX
    I have a pretty simple operation but am struggling with how to implement it. I am loading XML from an external data source using a DataSet.ReadXml(), the creating a new XMLDataDocument from that data set, then syncing the Dataset back to the XMLDataDocument like so: doc = new XmlDataDocument(dsDataSet); dsDataSet.EnforceConstraints = false; dsDataSet= doc.DataSet; Once loaded I do two things to the XmlDataDocument: Loop through and check if a purely meta node, count, exists right beneath the root node and if so remove it. a thumb node exists in a second level nodelist and if not, create and append it. This is all going a expected because the result of doc.save() looks correct. Where I'm having an issue is updating the Dataset, which is being applied as the data source for an ASP DataGrid. Once all the above XMLDoc manipaulation is done I do this: dsDataSet.Merge(doc.DataSet); dsDataSet.AcceptChanges(); I then apply the data set to the grid control: dgList.DataSource = dsDataSet; dgList.DataBind(); But, when I do this I get this error on the site: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'thumb'. What did I miss?

    Read the article

  • XML child node attribute value

    - by c0mrade
    I'm trying to read xml file, ex : <entry> <title>FEED TITLE</title> <id>5467sdad98787ad3149878sasda</id> <tempi type="application/xml"> <conento xmlns="http://mydomainname.com/xsd/radiofeed.xsd" madeIn="USA" /> </tempi> </entry> Here is the code I have so far : public void parseXML(String xml) { try { InputStream inputStream = new ByteArrayInputStream(xml.getBytes()); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(inputStream); doc.getDocumentElement().normalize(); System.out.println("Root element " + doc.getDocumentElement().getNodeName()); NodeList nodeLst = doc.getElementsByTagName("entry"); System.out.println("Information of all entries"); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element fstElmnt = (Element) fstNode; NodeList title = fstElmnt.getElementsByTagName("title").item(0).getChildNodes(); System.out.println("Title : " + ((Node) title.item(0)).getNodeValue()); NodeList id = fstElmnt.getElementsByTagName("id").item(0).getChildNodes(); System.out.println("Id: " + ((Node) update.item(0)).getNodeValue()); NodeList contento= fstElmnt.getElementsByTagName("tempi").item(0).getChildNodes(); System.out.println("Contento : " + ((Node) content.item(0)).getFirstChild().getAttributes()); // with this line above I'm having problems, I get null pointer exception } } } catch (Exception e) { e.printStackTrace(); } } How can I read/get, contento tag attributes? I'm using org.w3c.dom lib.

    Read the article

  • How do I get XML path by its value?

    - by user299938
    I need to get the xml path opf the xml file by providing the value of an xml child element as the input. For example: XML file: <?xml version="1.0"?> <document-inquiry xmlns="http://ops.epo.org"> <publication-reference data-format="docdb" xmlns="http://www.epo.org/exchange"> <document-id> <country>EP</country> <doc-number>1000</doc-number> <kind>A1</kind> </document-id> </publication-reference> </document-inquiry> For the above XML file. I need to get the XML path by using the value "1000". If my input is value of the element "1000" Output i need is : <document-id> <country>EP</country> <doc-number>1000</doc-number> <kind>A1</kind> </document-id> I need to achieve this using c# code. Can anyone please help me out on this...

    Read the article

  • Java XML Output - proper indenting for child items

    - by Dr1Ku
    Hello, I'd like to serialize some simple data model into xml, I've been using the standard java.org.w3c -related code (see below), the indentation is better than no "OutputKeys.INDENT", yet there is one little thing that remains - proper indentation for child elements. I know that this has been asked before on stackoverflow , yet that configuration did not work for me, this is the code I'm using : DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); doc = addItemsToDocument(doc); // The addItemsToDocument method adds childElements to the document. TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformerFactory.setAttribute("indent-number", new Integer(4)); // switching to setAttribute("indent-number", 4); doesn't help Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(outFile); // outFile is a regular File outFile = new File("some/path/foo.xml"); transformer.transform(source, result); The output produced is : <?xml version="1.0" encoding="UTF-8" standalone="no"?> <stuffcontainer> <stuff description="something" duration="240" title="abc"> <otherstuff /> </stuff> </stuffcontainer> Whereas I would want it (for more clarity) like : <?xml version="1.0" encoding="UTF-8" standalone="no"?> <stuffcontainer> <stuff description="something" duration="240" title="abc"> <otherstuff /> </stuff> </stuffcontainer> I was just wondering if there is a way of doing this, make it properly indented for the child elements. Thank you in advance ! Happy Easter coding :-) !

    Read the article

  • Modify XML existing content in C#

    - by Nano HE
    Purpose: I plan to Create a XML file with XmlTextWriter and Modify/Update some Existing Content with XmlNode SelectSingleNode(), node.ChildNode[?].InnerText = someting, etc. After I created the XML file with XmlTextWriter as below. XmlTextWriter textWriter = new XmlTextWriter("D:\\learning\\cs\\myTest.xml", System.Text.Encoding.UTF8); I practiced the code below. But failed to save my XML file. XmlDocument doc = new XmlDocument(); doc.Load("D:\\learning\\cs\\myTest.xml"); XmlNode root = doc.DocumentElement; XmlNode myNode; myNode= root.SelectSingleNode("descendant::books"); .... textWriter.Close(); doc.Save("D:\\learning\\cs\\myTest.xml"); I found it is not good to produce like my way. Is there any suggestion about it? I am not clear about the concepts and usage of both XmlTextWriter and XmlNode in the same project. Thank you for reading and replies.

    Read the article

  • How to get the output of an XslCompiledTransform into an XmlReader?

    - by Graham Clark
    I have an XslCompiledTransform object, and I want the output in an XmlReader object, as I need to pass it through a second stylesheet. I'm getting a bit confused - I can successfully transform some XML and read it using either a StreamReader or an XmlDocument, but when I try an XmlReader, I get nothing. In the example below, stylesheet is my XslCompiledTransform object. The first two Console.WriteLine calls output the correct transformed XML, but the third call gives no XML. I'm guessing it might be that the XmlTextReader is expecting text, so maybe I need to wrap this in a StreamReader..? What am I doing wrong? MemoryStream transformed = new MemoryStream(); stylesheet.Transform(input, args, transformed); transformed.Position = 0; StreamReader s = new StreamReader(transformed); Console.WriteLine("s = " + s.ReadToEnd()); // writes XML transformed.Position = 0; XmlDocument doc = new XmlDocument(); doc.Load(transformed); Console.WriteLine("doc = " + doc.OuterXml); // writes XML transformed.Position = 0; XmlReader reader = new XmlTextReader(transformed); Console.WriteLine("reader = " + reader.ReadOuterXml()); // no XML written

    Read the article

  • HTML file: add annotations through IHTMLDocument

    - by peterchen
    I need to add "annotations" to existing HTML documents - best in the form of string property values I can read & write by name. Apparently (to me), meta elements in the header seem to be the common way - i.e. adding/modifying elements like <head> <meta name="unique-id_property-name" content="property-value"/> ... </head> Question 1: Ist that "acceptable" / ok, or is there a better way to add meta data? I have a little previous experience with getting/mut(il)ating HTML contents through the document in an web browser control. For this task, I've already loaded the HTML document into a HTMLDocument object, but I'm not sure how to go on: // what I have IHTMLDocument2Ptr doc; doc.CreateInstance(__uuidof(HTMLDocument)); IPersistFile pf = doc; pf->Load(fileName, STGM_READ); // everything ok until here Questions 2: Should I be using anything else than HTMLDocument? Questions 3..N: How do I get the head element? How do I get the value of a meta element with a given name? How do I set the value of a meta element (adding the item if and only if it doesn't exist yet)? doc->all returns a collection of all tags, which I can enumerate even though count returns 0. I could scan that for head, then scan that for all meta where the name starts with a certain string, etc. - but this feels very clumsy.

    Read the article

  • Error in Getting Youtube Video Title, Description and thumbnail

    - by Muhammad Ayyaz Zafar
    I was getting youtube title and youtube description form the same code but now its not working I am getting following error: Warning: DOMDocument::load() [domdocument.load]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/colorsfo/public_html/zaroorat/admin/pages/addSongProcess.php on line 16 Warning: DOMDocument::load(http://gdata.youtube.com/feeds/api/videos/Y7G-tYRzwYY) [domdocument.load]: failed to open stream: no suitable wrapper could be found in /home/colorsfo/public_html/zaroorat/admin/pages/addSongProcess.php on line 16 Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://gdata.youtube.com/feeds/api/videos/Y7G-tYRzwYY" in /home/colorsfo/public_html/zaroorat/admin/pages/addSongProcess.php on line 16 .................................... Following Coding is used to get Youtube Video Data: $url = "http://gdata.youtube.com/feeds/api/videos/".$embedCodeParts2[0]; $doc = new DOMDocument; @$doc->load($url); $title = $doc->getElementsByTagName("title")->item(0)->nodeValue; $videoDescription = $doc->getElementsByTagName("description")->item(0)->nodeValue; It was working before (This coding is working fine in Local server but on internet its not working) but now its not working. Please guide me how to fix this error. Thanks for your time.

    Read the article

  • parsing xml using dom4j

    - by D3GAN
    My XML structure is like this: <rss> <channel> <yweather:location city="Paris" region="" country="France"/> <yweather:units temperature="C" distance="km" pressure="mb" speed="km/h"/> <yweather:wind chill="-1" direction="40" speed="11.27"/> <yweather:atmosphere humidity="87" visibility="9.99" pressure="1015.92" rising="0"/> <yweather:astronomy sunrise="8:30 am" sunset="4:54 pm"/> </channel> </rss> when I tried to parse it using dom4j SAXReader xmlReader = createXmlReader(); Document doc = null; doc = xmlReader.read( inputStream );//inputStream is input of function log.info(doc.valueOf("/rss/channel/yweather:location/@city")); private SAXReader createXmlReader() { Map<String,String> uris = new HashMap<String,String>(); uris.put( "yweather", "http://xml.weather.yahoo.com/ns/rss/1.0" ); uris.put( "geo", "http://www.w3.org/2003/01/geo/wgs84_pos#" ); DocumentFactory factory = new DocumentFactory(); factory.setXPathNamespaceURIs( uris ); SAXReader xmlReader = new SAXReader(); xmlReader.setDocumentFactory( factory ); return xmlReader; } But I got nothing in cmd but when I print doc.asXML(), my XML structure print correctly!

    Read the article

  • Trying to replace contents of a Div, with no luck

    - by bluedaniel
    Ive tried to use the Dom model with no bloody luck, getElementByID just doesnt work for me. I loathe to resort to a regex but not sure what else to do. The idea is to replace a <div id="content_div"> all sorts </div> with a new <div id="content_div"> NEW ALL SORTS HERE </div> and keep anything that was before or after it in the string. The string is a partial HTML string and more specifically out of the wordpress Posts DB. Any ideas? UPDATE: I tagged this question PHP but probably should of mentioned Im looking for a PHP solution only. Update: Code Example $content = ($wpdb->get_var( "SELECT `post_content` FROM $wpdb->posts WHERE ID = {$article[post_id]}" )); $doc = new DOMDocument(); $doc->validateOnParse = true; $doc->loadHTMLFile($content); $element = $doc->getElementById('div_to_edit'); So Ive tried a whole lot of code and this is what Ive got so far, probably not right but Ive been hacking at it for a little while now.

    Read the article

  • Parsing the Youtube API with DOM

    - by Kirk
    I'm using the Youtube API and I can retrieve the date information without a problem, but don't know how to retrieve the description information. My Code: <?php $v = "dQw4w9WgXcQ"; $url = "http://gdata.youtube.com/feeds/api/videos/". $v; $doc = new DOMDocument; $doc->load($url); $pub = $doc->getElementsByTagName("published")->item(0)->nodeValue; $desc = $doc->getElementsByTagName("media:description")->item(0)->nodeValue; echo "<b>Video Uploaded:</b> "; echo date( "F jS, Y", strtotime( $pub ) ); echo '<br>'; if (isset ($desc)) { echo "<b>Description:</b> "; echo $desc; echo '<br>'; } ?> Here's a link to the feed: http://gdata.youtube.com/feeds/api/videos/dQw4w9WgXcQ?prettyprint=true And the excerpt of code I don't know how to retrieve data from: <media:group> <media:description type='plain'>Music video by Rick Astley performing Never Gonna Give You Up. (C) 1987 PWL</media:description> </media:group> Thanks in advance.

    Read the article

  • DOM manipulation in PHP

    - by bluedaniel
    Hello everyone, Im trying to use the DOM in PHP to do a pretty specific job and Ive got no luck so far, the objective is to take a string of HTML from a Wordpress blog post (from the DB, this is a wordpress plugin). And then out of that HTML replace <div id="do_not_edit">old content</div>" with <div id="do_not_edit">new content</div>" in its place. Saving anything above and below that div in its structure. Then save the HTML back into the DB, should be simple really, I have read that a regex wouldnt be the right way to go here so Ive turned to the DOM instead. The problem is I just cant get it to work, cant extract the div or anything. Help me!! UPDATE The HTML coming out of the wordpress table looks like: Congratulations on finding us here on the world wide web, we are on a mission to create a website that will show off your culinary skills better than any other website does. <div id="do_not_edit">blah blah</div> We want this website to be fun and easy to use, we strive for simple elegance and incredible functionality.We aim to provide a 'complete package'. By this we want to create a website where people can meet, share ideas and help each other out. After several different (incorrect) workings all Ive got below is: $content = ($wpdb->get_var( "SELECT `post_content` FROM $wpdb->posts WHERE ID = {$article[post_id]}" )); $doc = new DOMDocument(); $doc->validateOnParse = true; $doc->loadHTMLFile($content); $element = $doc->getElementById('do_not_edit'); echo $element;

    Read the article

  • XML Decryption Bug (referencing issue)

    - by OrangePekoe
    Hi, Needing some explanation of what exactly the decryption is doing, in addition to some help on solving the problem. Currently, when a portion of XML is encrypted, and then decrypted, the DOM appears to work correctly. We can see the element is encrypted and then see it return back once it is decrypted. Our problem lies when a user tries to change data in that same element after decryption has occurred. When a user changes some settings, data in the XML should change. However, if the user attempts to change an XML element that has been decrypted the changes are not reflected in the DOM. We have a reference pointer to the XML element that is used to bind the element to an object. If you encrypt the node and then decrypt it, the reference pointer now points to a valid orphaned XML element that is no longer part of the DOM. After decryption, there will be 2 copies of the XML element. One in the DOM as expected (though will not reflect new changes), and one orphaned element in memory that is still referenced by our pointer. The orphaned element is valid (reflects new changes). We can see that this orphaned element is owned by the DOM, but when we try to return its parent, it returns null. The question is: Where did this orphaned xml element come from? And how can we get it to correctly append (replace old data) to the DOM? The code resembles: public static void Decrypt(XmlDocument Doc, SymmetricAlgorithm Alg) { if (Doc == null) throw new ArgumentNullException("Doc"); if (Alg == null) throw new ArgumentNullException("Alg"); XmlElement encryptedElement = Doc.GetElementsByTagName("EncryptedData")[0] as XmlElement; if (encryptedElement == null) { throw new XmlException("The EncryptedData element was not found."); } EncryptedData edElement = new EncryptedData(); edElement.LoadXml(encryptedElement); EncryptedXml exml = new EncryptedXml(); byte[] rgbOutput = exml.DecryptData(edElement, Alg); exml.ReplaceData(encryptedElement, rgbOutput); }

    Read the article

  • invalid scalar hex value 0x8000000 and over

    - by kioto
    Hi. I found a problem getting hex value from yaml file. It couldn't get hex value 0x80000000 and over. Following is a sample C++ program. // ymlparser.cpp #include <iostream> #include <fstream> #include "yaml-cpp/yaml.h" int main(void) { try { std::ifstream fin("hex.yaml"); YAML::Parser parser(fin); YAML::Node doc; parser.GetNextDocument(doc); int num1; doc["hex1"] >> num1; printf("num1 = 0x%x\n", num1); int num2; doc["hex2"] >> num2; printf("num2 = 0x%x\n", num2); return 0; } catch(YAML::ParserException& e) { std::cout << e.what() << "\n"; } } hex.yaml hex1: 0x7FFFFFFF hex2: 0x80000000 Error message is here. $ ./ymlparser num1 = 0x7fffffff terminate called after throwing an instance of 'YAML::InvalidScalar' what(): yaml-cpp: error at line 2, column 7: invalid scalar Aborted Environment yaml-cpp : getting from svn, March.22.2010 or v0.2.5 OS : Ubuntu 9.10 i386 I need to get hex the value on yaml-cpp now, but I have no idea. Please tell me how to get it another way. Thanks,

    Read the article

  • problem with two key ranges in couchdb

    - by Duasto
    I'm having problem getting the right results in my coordinate system. To explain my system, I have this simple database that have x_axis, y_axis and name columns. I don't need to get all the data, I just need to display some part of it. For example, I have a coordinate system that have 10:10(meaning from x_axis -10 to 10 and from y_axis -10 to 10) and I want to display only 49 coordinates. In sql query I can do it something like this: "select * from coordinate where x_axis = -3 and x_axis <= 3 and y_axis = -3 y_axis <= 3" I tried this function but no success: "by_range": { "map": "function(doc) { emit([doc.x_axis, doc.y_axis], doc) }" } by_range?startkey=[-3,-3]&endkey=[3,3] I got a wrong results of: -3x-3 -3x-2 -3x-1 -3x0 -3x1 -3x2 -3x3 <-- should not display this part -- -3x4 -3x5 -3x6 -3x7 -3x8 -3x9 -3x10 <-- end of should not display this part -- ..... up to 3x3 to give you a better understanding of my project here is the screenshot of that I want to be made: Oops they don't allowed new poster to post an image img96(dot)imageshack(dot)us/img96/5382/coordinates(dot)jpg <<< just change the "(dot)" to "."

    Read the article

  • java: how to parse html-like xml

    - by Yang
    I have an html-like xml, basically it is html. I need to get the elements in each . Each element looks like this: <line tid="744476117"> <attr>1414</attr> <attr>31</attr><attr class="thread_title">title1</attr><attr>author1</attr><attr>date1</attr></line> My code is as below, it does recognize that there are 50 in the file, but it gives me NULLPointException when parsing NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("attr"); Any idea why this is happening? The same code has been used for other applications without problems. DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(cleanxml)); Document doc = db.parse(is); doc.getDocumentElement().normalize(); System.out.println("Root element " + doc.getDocumentElement().getNodeName()); NodeList nodeLst = doc.getElementsByTagName("line"); for (int s = 0; s < nodeLst.getLength(); s++) { System.out.println(nodeLst.getLength()); Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element fstElmnt = (Element) fstNode; NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("attr"); Element fstNmElmnt = (Element) fstNmElmntLst.item(0); NodeList fstNm = fstNmElmnt.getChildNodes(); System.out.println("attr : " + ((Node) fstNm.item(0)).getNodeValue()); } }

    Read the article

  • DOM manipulation

    - by bluedaniel
    Hello everyone, Im trying to use the DOM in PHP to do a pretty specific job and Ive got no luck so far, the objective is to take a string of HTML from a Wordpress blog post (from the DB, this is a wordpress plugin). And then out of that HTML replace <div id="do_not_edit">old content</div>" with <div id="do_not_edit">new content</div>" in its place. Saving anything above and below that div in its structure. Then save the HTML back into the DB, should be simple really, I have read that a regex wouldnt be the right way to go here so Ive turned to the DOM instead. The problem is I just cant get it to work, cant extract the div or anything. Help me!! UPDATE The HTML coming out of the wordpress table looks like: Congratulations on finding us here on the world wide web, we are on a mission to create a website that will show off your culinary skills better than any other website does. <div id="do_not_edit">blah blah</div> We want this website to be fun and easy to use, we strive for simple elegance and incredible functionality.We aim to provide a 'complete package'. By this we want to create a website where people can meet, share ideas and help each other out. After several different (incorrect) workings all Ive got below is: $content = ($wpdb->get_var( "SELECT `post_content` FROM $wpdb->posts WHERE ID = {$article[post_id]}" )); $doc = new DOMDocument(); $doc->validateOnParse = true; $doc->loadHTMLFile($content); $element = $doc->getElementById('do_not_edit'); echo $element;

    Read the article

  • Ruby - Nokogiri - Parsing XML from memory and putting all same name node values into an array.

    - by r3nrut
    I have an XML I'm trying to parse from memory and get the status of each of my heart beat tests using Nokogiri. Here is the solution I have... xml = <a:HBeat> <a:ElapsedTime>3 ms</a:ElapsedTime> <a:Name>Service 1</a:Name> <a:Status>true</a:Status> </a:HBeat> <a:HBeat> <a:ElapsedTime>4 ms</a:ElapsedTime> <a:Name>Service 2</a:Name> <a:Status>true</a:Status> </a:HBeat> <a:HBeat> I have tried using both css and xpath to pull back the value for each Status and put it into an array. Code is below: doc = Nokogiri::XML.parse(xml) #service_state = doc.css("a:HBeat, a:Status", 'a' => 'http://schemas.datacontract.org/2004/07/OpenAPI.Entity').map {|node| node.children.text} service_state = doc.xpath("//*[@a:Status]", 'a' => 'http://schemas.datacontract.org/2004/07/OpenAPI.Entity').map(&:text) Both will return service_state = []. Any thoughts or recommendations? Also, consider that I have almost identical xml for another test and I used the following snippet of code which does exactly what I wanted but for some reason isn't working with the xml that contains namespaces. service_state = doc.css("HBeat Status").map(&:text) Thanks!

    Read the article

  • How to get attribute value using SelectSingleNode in C#?

    - by Nano HE
    Hello. I am parsing a xml document, I need find out the gid (an attribute) value (3810). Based on SelectSingleNode(). I found it is not easy to find the attribute name and it's value. Can I use this method or I must switch to other way. Attached my code. How can I use book obj to get the attribute value3810 for gid. Thank you. My test.xml file as below <?xml version="1.0"?> <root> <VersionInfo date="2007-11-28" version="1.0.0.2"/> <Attributes> <AttrDir name="EFEM" DirID="1"> <AttrDir name="Aligner" DirID="2"> <AttrDir name="SequenceID" DirID="3"> <AttrObj text="Slot01" gid="3810" unit="" scale="1"/> <AttrObjCount value="1"/> </AttrDir> </AttrDir> </AttrDir> </Attributes> </root> I wrote the test.cs as below public class Sample { public static void Main() { XmlDocument doc = new XmlDocument(); doc.Load("test.xml"); XmlNode book; XmlNode root = doc.DocumentElement; book = root.SelectSingleNode("Attributes[AttrDir[@name='EFEM']/AttrDir[@name='Aligner']/AttrDir[@name='SequenceID']/AttrObj[@text='Slot01']]"); Console.WriteLine("Display the modified XML document...."); doc.Save(Console.Out); } }

    Read the article

  • How to insert data in xml file using php?

    - by Nitesh
    <?xml version="1.0" encoding="UTF-8"?> <root></root> This is my xml file. I want to insert-update data using the dom method in between the tags. I am a beginner in php and Xml technologies. I successfully created and read from this file but not been able to enter data in it using php. The code for creating is as follows:- $doc = new DOMDocument('1.0', 'UTF-8'); $ele = $doc->createElement( 'root' ); $ele->nodeValue = $uvar; $doc->appendChild( $ele ); $test = $doc->save("$id.xml"); The code for reading is as follows:- $xdoc = new DOMDocument( ); $xdoc->Load("$gid.xml"); $candidate = $xdoc->getElementsByTagName('root')->item(0); $newElement = $xdoc ->createElement('root'); $txtNode = $xdoc ->createTextNode ($root); $newElement -> appendChild($txtNode); $candidate -> appendChild($newElement); $msg = $candidate->nodeValue; Can someone help out with inserting and updating. Thank You!

    Read the article

  • Getting document.getElementsByName from another page PHP/javascript

    - by DarkN3ss
    so i have been looking around on how to do this but with no success. Im trying to get the value of the name test from an external website <input type="hidden" name="test" value="ThisIsAValue" /> But so far i have only found how to get the value of that with an ID <input type="hidden" id="test" name="test" value="ThisIsAValue" autocomplete="off" /> but I need to try find it without a ID is my problem. And this is an example on how to get it from the ID <?php $doc = new DomDocument; $doc->validateOnParse = true; $doc->loadHtml(file_get_contents('http://example.com/bla.php')); var_dump($doc->getElementById('test')); ?> And i have found how to get it from name and NOT ID on the same page <script> function getElements() { var test = document.getElementsByName("test")[0].value; alert(test); } </script> But again I dont know how to get the value of it by name from an external page eg "http://example.com/bla.php", any help? Thanks

    Read the article

  • xpath php attributes not working?

    - by Jared
    Getting this error Call to a member function attributes() on a non-object I have found multiple answers to this on SO, but none of them seem to solve my problem? Here is the XML: <Routes> <Route type="source" name="incoming"> </Route> <Routes> Here is the PHP: $doc = new SimpleXMLElement('routingConfig.xml', null, true); class traverseXML { function getData() { global $doc; $routeCount = count($doc -> xpath("Route")); //this value returns correctly $routeArr = array(); for ($i = 1; $i <= $routeCount; $i++) { $name = $doc -> Route[$i] -> attributes() -> name; array_push($routeArr, $name); } return $routeArr; } } $traverseXML = new traverseXML; var_dump($traverseXML -> getData()); I understand what the error means, but how is it a non-object? How do I return the name attribute of Routes/Route[1] ?

    Read the article

  • Need Explanation of couchdb reduce function

    - by Alan
    From http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views The couchdb reduce function is defined as function (key, values, rereduce) { return sum(values); } key will be an array whose elements are arrays of the form [key,id] values will be an array of the values emitted for the respective elements in keys i.e. reduce([ [key1,id1], [key2,id2], [key3,id3] ], [value1,value2,value3], false) I am having trouble understanding when/why the array of keys would contain different key values. If the array of keys does contain different key values, how would I deal with it? As an example, assume that my database contains movements between accounts of the form. {"amount":100, "CreditAccount":"account_number", "DebitAccount":"account_number"} I want a view that gives the balance of an account. My map function does: emit( doc.CreditAccount, doc.amount ) emit( doc.DebitAccount, -doc.amount ) My reduce function does: return sum(values); I seem to get the expected results, however I can't reconcile this with the possibility that my reduce function gets different key values. Is my reduce function supposed to group key values first? What kind of result would I return in that case?

    Read the article

  • How to use XML namespace prefixes without xmlns="..." everywhere? (.NET)

    - by LonelyPixel
    The subject is probably too short to explain it... I'm writing out XML files with no namespace stuff at all, for some application. That part I cannot change. But now I'm going to extend those files with my own application-defined element names, and I'd like to put them in a different namespace. For this, the result should look like this: <doc xmlns:x="urn:my-app-uri"> <a>existing element name</a> <x:addon>my additional element name</x:addon> </doc> I've used an XmlNamespaceManager and added my URI with the prefix "x" to it. I've also passed it to each CreateElement for my additional element names. But the nearest I can get is this: <doc> <a>existing element name</a> <addon xmlns="urn:my-app-uri">my additional element name</addon> </doc> Or maybe also <x:addon xmlns:x="urn:my-app-uri">my additional element name</x:addon> So the point is that my URI is written to every single of my additional elements, and no common prefix is written to the document element where I'd like to have it. How can I get the above XML result with .NET?

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >