setNodeValue not working

Discussion in 'XML' started by keepyourstupidspam, Nov 14, 2005.

  1. Can anyone please tell me why this code is not working for me. I can
    add the error handling again, XML file is below. I want to change the
    currentState element from pending to Submitted.

    int DataStore::UpdateMetaData1(string SubmissionID, string Key, string
    Value)
    {
    XercesDOMParser* parser = new XercesDOMParser();
    parser->setValidationScheme(XercesDOMParser::Val_Never); //
    optional.
    parser->setDoNamespaces(true); // optional

    string metadataFile = GetMetadataFileName(SubmissionID);
    parser->parse(metadataFile.c_str());
    xercesc_2_4::DOMDocument* m_document = parser->getDocument();

    DOMNodeList* Info =
    m_document->getElementsByTagName(XMLString::transcode("IS_MetaData"));
    DOMElement* pElem = (DOMElement*)Info->item(0);

    DOMNodeList *pList =
    pElem->getElementsByTagName(XMLString::transcode(Key.c_str()));
    if( pList->getLength() > 0 )
    {
    DOMElement *pElem = (DOMElement *)pList->item( 0 );
    DOMNode *pChild = pElem->getFirstChild();

    if( pChild )
    {
    pChild->setNodeValue(XMLString::transcode(Value.c_str()));
    }
    }

    return A_OK;
    }



    <IS_MetaData>
    <submissionID>12345</submissionID>
    <SubmissionDate>11 14 2005</SubmissionDate>
    <submissionType>Whatever</submissionType>
    <description>Test Incident</description>
    <currentState>Pending</currentState>
    <annotations>Testing the data store manager</annotations>
    <workflowID>0</workflowID>
    <business>automobile</business>
    <deviceName>Minime</deviceName>
    <deviceIP>18.289.134.252</deviceIP>
    <submissionDataFile>0</submissionDataFile>
    <attachments>S:\IS\A.05.00\dev\main\src\client\windows\xpis\datastoreManager\test\12345\ClientManager.map;</attachments>
    <numAttachments>3</numAttachments>
    </IS_MetaData>

    Thanks,
    Enda
     
    keepyourstupidspam, Nov 14, 2005
    #1
    1. Advertising

  2. >From a similar example I was reading the above code only sets the value
    in memory can someone tell me how I can set it in the file
    persistantly.

    Thanks,
    Enda
     
    keepyourstupidspam, Nov 15, 2005
    #2
    1. Advertising

  3. keepyourstupidspam wrote:

    >>From a similar example I was reading the above code only sets the value

    > in memory can someone tell me how I can set it in the file
    > persistantly.


    DOMWriter should help with that:
    <http://xml.apache.org/xerces-c/apiDocs/classDOMWriter.html>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Nov 15, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ratman
    Replies:
    0
    Views:
    709
    Ratman
    Sep 14, 2004
  2. Martin Heuckeroth
    Replies:
    5
    Views:
    721
    JiangZemin
    Apr 1, 2005
  3. Alan Silver
    Replies:
    1
    Views:
    3,812
    Alan Silver
    Aug 2, 2005
  4. gaurav tyagi
    Replies:
    14
    Views:
    1,374
    gaurav tyagi
    Jan 20, 2006
  5. Priyanka AGARWAL
    Replies:
    9
    Views:
    10,099
    Gordon Beaton
    May 25, 2004
Loading...

Share This Page